Is item in the collection ?

Comparisons are done with ==

assert [1,2,3].has(2)    == true
assert [1,2,3].has(9)    == false
assert [1..5[.has(2)     == true
assert [1..5[.has(9)     == false

Property definitions

core $ Collection :: has
	# Is `item` in the collection ?
	# Comparisons are done with ==
	#
	#     assert [1,2,3].has(2)    == true
	#     assert [1,2,3].has(9)    == false
	#     assert [1..5[.has(2)     == true
	#     assert [1..5[.has(9)     == false
	fun has(item: nullable Object): Bool
	do
		for i in self do if i == item then return true
		return false
	end
lib/core/collection/abstract_collection.nit:88,2--99,4

core $ Range :: has
	#     assert [1..10].has(5)
	#     assert [1..10].has(10)
	#     assert not [1..10[.has(10)
	redef fun has(item) do return item isa Comparable and item >= first and item <= last
lib/core/collection/range.nit:30,2--33,85

pthreads $ ConcurrentCollection :: has
	redef fun has(e)
	do
		mutex.lock
		var r = real_collection.has(e)
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:100,2--106,4

core $ Ref :: has
	redef fun has(an_item) do return item == an_item
lib/core/collection/abstract_collection.nit:364,2--49

core $ AbstractArrayRead :: has
	redef fun has(item)
	do
		var i = 0
		var l = length
		while i < l do
			if self[i] == item then return true
			i += 1
		end
		return false
	end
lib/core/collection/array.nit:30,2--39,4

core $ ArrayMapKeys :: has
	redef fun has(k) do return self.map.index(k) >= 0
lib/core/collection/array.nit:808,2--50

core $ ArrayMapValues :: has
	# O(n)
	redef fun has(item)
	do
		for i in self.map._items do if i.second == item then return true
		return false
	end
lib/core/collection/array.nit:831,2--836,4

core $ HashMapKeys :: has
	redef fun has(k) do return self.map.node_at(k) != null
lib/core/collection/hash_collection.nit:292,2--55

core $ HashMapValues :: has
	redef fun has(item)
	do
		var c = self.map._first_item
		while c != null do
			if c._value == item then return true
			c = c._next_item
		end
		return false
	end
lib/core/collection/hash_collection.nit:323,2--331,4

ordered_tree $ OrderedTree :: has
	redef fun has(e) do return parents.has_key(e)
lib/ordered_tree/ordered_tree.nit:80,2--46

poset $ POSet :: has
	redef fun has(e) do return self.elements.keys.has(e)
lib/poset/poset.nit:89,2--53

core $ DisjointSet :: has
	# Is the element in the structure
	#
	#     var s = new DisjointSet[Int]
	#     assert not s.has(1)
	#     s.add(1)
	#     assert s.has(1)
	#     assert not s.has(2)
	redef fun has(e) do
		return nodes.has_key(e)
	end
lib/core/collection/union_find.nit:112,2--121,4

core $ ArraySet :: has
	redef fun has(e) do return _array.has(e)
lib/core/collection/array.nit:600,2--41

core $ List :: has
	# O(n)
	redef fun has(e) do return search_node_after(e, _head) != null
lib/core/collection/list.nit:48,2--49,63

dom $ XMLEntities :: has
	redef fun has(e) do return entities.has(e)
lib/dom/xml_entities.nit:95,2--43

dummy_array $ DummyArray :: has
	redef fun has(value)
	do
		if not value isa Int then return false
		assert value < _capacity
		var pos = _keys[value]
		if pos < _length then
			return _values[pos] == value
		end
		return false
	end
lib/dummy_array/dummy_array.nit:45,2--54,4

core $ HashSet :: has
	redef fun has(item)
	do
		return node_at(item) != null
	end
lib/core/collection/hash_collection.nit:442,2--445,4

core $ Bytes :: has
	redef fun has(c)
	do
		if not c isa Int then return false
		return super(c&255)
	end
lib/core/bytes.nit:541,2--545,4

pthreads $ ConcurrentArray :: has
	redef fun has(e)
	do
		mutex.lock
		var result = real_collection.has(e)
		mutex.unlock
		return result
	end
lib/pthreads/concurrent_collections.nit:424,2--430,4