+# MapRead are abstract associative collections: `key` -> `item`.
+interface MapRead[K, V]
+ # Get the item at `key`
+ #
+ # var x = new HashMap[String, Int]
+ # x["four"] = 4
+ # assert x["four"] == 4
+ # # assert x["five"] #=> abort
+ #
+ # If the key is not in the map, `provide_default_value` is called (that aborts by default)
+ # See `get_or_null` and `get_or_default` for safe variations.
+ fun [](key: K): V is abstract
+
+ # Get the item at `key` or null if `key` is not in the map.
+ #
+ # var x = new HashMap[String, Int]
+ # x["four"] = 4
+ # assert x.get_or_null("four") == 4
+ # assert x.get_or_null("five") == null
+ #
+ # Note: use `has_key` and `[]` if you need the distinction between a key associated with null, and no key.
+ fun get_or_null(key: K): nullable V
+ do
+ if has_key(key) then return self[key]
+ return null
+ end
+
+ # Get the item at `key` or return `default` if not in map
+ #
+ # var x = new HashMap[String, Int]
+ # x["four"] = 4
+ # assert x.get_or_default("four", 40) == 4
+ # assert x.get_or_default("five", 50) == 50
+ #
+ fun get_or_default(key: K, default: V): V
+ do
+ if has_key(key) then return self[key]
+ return default
+ end
+
+ # 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 iterator: MapIterator[K, V] is abstract
+
+ # Return the point of view of self on the values only.
+ # Note that `self` and `values` are views on the same data;
+ # therefore any modification of one is visible on the other.
+ #
+ # var x = new HashMap[String, Int]
+ # x["four"] = 4
+ # assert x.values.has(4) == true
+ # assert x.values.has(5) == false
+ fun values: Collection[V] is abstract
+
+ # Return the point of view of self on the keys only.
+ # Note that `self` and `keys` are views on the same data;
+ # therefore any modification of one is visible on the other.
+ #
+ # var x = new HashMap[String, Int]
+ # x["four"] = 4
+ # assert x.keys.has("four") == true
+ # assert x.keys.has("five") == false
+ fun keys: Collection[K] is abstract
+
+ # Is there no item in the collection?
+ #
+ # var x = new HashMap[String, Int]
+ # assert x.is_empty == true
+ # x["four"] = 4
+ # assert x.is_empty == false
+ fun is_empty: Bool is abstract
+
+ # Number of items in the collection.
+ #
+ # var x = new HashMap[String, Int]
+ # assert x.length == 0
+ # x["four"] = 4
+ # assert x.length == 1
+ # x["five"] = 5
+ # assert x.length == 2
+ fun length: Int is abstract