Is there an item associated with key?

var x = new HashMap[String, Int]
x["four"] = 4
assert x.has_key("four") == true
assert x.has_key("five") == false

By default it is a synonymous to keys.has but could be redefined with a direct implementation.

Property definitions

core $ MapRead :: has_key
	# Is there an item associated with `key`?
	#
	#     var x = new HashMap[String, Int]
	#     x["four"] = 4
	#     assert x.has_key("four") == true
	#     assert x.has_key("five") == false
	#
	# By default it is a synonymous to `keys.has` but could be redefined with a direct implementation.
	fun has_key(key: nullable Object): Bool do return self.keys.has(key)
lib/core/collection/abstract_collection.nit:572,2--580,69

core $ CoupleMap :: has_key
	redef fun has_key(key) do return couple_at(key) != null
lib/core/collection/abstract_collection.nit:1296,2--56

trees $ Trie :: has_key
	redef fun has_key(key) do
		var node = search_node(key)
		if node == null then return false
		var res = node.is_leaf
		if res then
			cache = node
			cache_key = key.as(String)
		end
		return res
	end
lib/trees/trie.nit:106,2--115,4

core $ HashMap :: has_key
	redef fun has_key(k) do return node_at(k) != null
lib/core/collection/hash_collection.nit:281,2--50

trees $ BinTreeMap :: has_key
	# O(n) in worst case, average is O(h) with h: tree height
	#
	#     var tree = new BinTreeMap[Int, String]
	#     assert not tree.has_key(1)
	#     for i in [4, 2, 1, 5, 3] do tree[i] = "n{i}"
	#     assert not tree.has_key(0)
	#     assert tree.has_key(2)
	#     assert not tree.has_key(6)
	redef fun has_key(key) do
		if is_empty then return false
		var res = search_down(root.as(not null), key)
		if res != null then
			cache_node = res
			return true
		end
		return false
	end
lib/trees/bintree.nit:60,2--76,4

ini $ IniFile :: has_key
	# Is there a property located at `key`?
	#
	# Returns `true` if the `key` is not found of if its associated value is `null`.
	#
	# ~~~
	# var ini = new IniFile.from_string("""
	# key=value1
	# [section1]
	# key=value2
	# [section2]
	# key=value3
	# """)
	# assert ini.has_key("key")
	# assert ini.has_key("section1.key")
	# assert ini.has_key("section2.key")
	# assert not ini.has_key("section1")
	# assert not ini.has_key("not.found")
	# ~~~
	redef fun has_key(key) do return self[key] != null
lib/ini/ini.nit:178,2--196,51