Signed-off-by: Jean Privat <jean@pryen.org>
+ # 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: K): Bool do return self.keys.has(key)
# Get a new iterator on the map.
fun has_key(key: K): Bool do return self.keys.has(key)
# Get a new iterator on the map.
+
+ redef fun has_key(key) do return couple_at(key) != null
end
# Iterator on CoupleMap
end
# Iterator on CoupleMap
redef var keys: RemovableCollection[K] = new HashMapKeys[K, V](self)
redef var values: RemovableCollection[V] = new HashMapValues[K, V](self)
redef var keys: RemovableCollection[K] = new HashMapKeys[K, V](self)
redef var values: RemovableCollection[V] = new HashMapValues[K, V](self)
+ redef fun has_key(k) do return node_at(k) != null
end
# View of the keys of a HashMap
end
# View of the keys of a HashMap