# Get a new iterator on the collection.
fun iterator: Iterator[E] is abstract
+ # Iterate over each element of the collection
+ fun iterate
+ !each(e: E)
+ do
+ var i = iterator
+ while i.is_ok do
+ each(i.item)
+ i.next
+ end
+ end
+
# Is there no item in the collection ?
fun is_empty: Bool is abstract
redef fun length
do
var nb = 0
- for i in self do nb += nb
+ for i in self do nb += 1
return nb
end
# ...
# s.add(a)
# s.has(b) # --> true
-interface Set[E]
+interface Set[E: Object]
special SimpleCollection[E]
redef fun has_only(item)
redef fun remove_all(item) do remove(item)
end
-interface MapRead[K, E]
+interface MapRead[K: Object, E]
special Collection[E]
# Get the item at `key'.
fun [](key: K): E is abstract
# map[u2] # -> v2
# map.has_key(u1) # -> true
# map.has_key(u3) # -> false
-interface Map[K, E]
+interface Map[K: Object, E]
special RemovableCollection[E]
special MapRead[K, E]
# Set the`item' at `key'.
end
# Iterators for Map.
-interface MapIterator[K, E]
+interface MapIterator[K: Object, E]
special Iterator[E]
# The key of the current item.
fun key: K is abstract
# Indexed collection are ordoned collections.
# The first item is 0. The last is `length'-1.
-interface IndexedCollectionRead[E]
+interface SequenceRead[E]
special MapRead[Int, E]
# Get the first item.
# Is equivalent with `self'[0].
# Indexed collection are ordoned collections.
# The first item is 0. The last is `length'-1.
-interface IndexedCollection[E]
-special IndexedCollectionRead[E]
+interface Sequence[E]
+special SequenceRead[E]
special Map[Int, E]
special SimpleCollection[E]
# Set the first item.
end
# Associatives arrays that internally uses couples to represent each (key, value) pairs.
-interface CoupleMap[K, E]
+interface CoupleMap[K: Object, E]
special Map[K, E]
# Return the couple of the corresponding key
# Return null if the key is no associated element
# Iterator on CoupleMap
#
# Actually is is a wrapper around an iterator of the internal array of the map.
-class CoupleMapIterator[K, E]
+class CoupleMapIterator[K: Object, E]
special MapIterator[K, E]
redef fun item do return _iter.item.second