Since keys of Maps can now be null, it enables the same rule with the Sets
authorJean Privat <jean@pryen.org>
Fri, 30 Jan 2015 09:36:28 +0000 (16:36 +0700)
committerJean Privat <jean@pryen.org>
Fri, 30 Jan 2015 09:36:28 +0000 (16:36 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/counter.nit
lib/poset.nit
lib/standard/collection/abstract_collection.nit
lib/standard/collection/array.nit
lib/standard/collection/hash_collection.nit
lib/standard/collection/union_find.nit

index 3d1555b..6545b73 100644 (file)
@@ -35,7 +35,7 @@ import poset
 # assert c.max    == "b" # because "b" has the most count (3)
 # assert c.avg    == 2.0 # because it is the mean of the counts
 # ~~~~
-class Counter[E: Object]
+class Counter[E]
        super Map[E, Int]
 
        # Total number of counted occurrences
@@ -181,7 +181,8 @@ class Counter[E: Object]
        fun max: nullable E do
                var max: nullable Int = null
                var elem: nullable E = null
-               for e, v in map do
+               for e in map.keys do
+                       var v = map[e]
                        if max == null or v > max then
                                max = v
                                elem = e
@@ -201,7 +202,8 @@ class Counter[E: Object]
        fun min: nullable E do
                var min: nullable Int = null
                var elem: nullable E = null
-               for e, v in map do
+               for e in map.keys do
+                       var v = map[e]
                        if min == null or v < min then
                                min = v
                                elem = e
@@ -238,7 +240,7 @@ class Counter[E: Object]
        end
 end
 
-private class CounterComparator[E: Object]
+private class CounterComparator[E]
        super Comparator
        redef type COMPARED: E
        var counter: Counter[E]
index a5425dd..568f968 100644 (file)
@@ -71,7 +71,7 @@ module poset
 #
 # Thanks to the `[]` method, elements can be considered relatively to the poset.
 # SEE `POSetElement`
-class POSet[E: Object]
+class POSet[E]
        super Collection[E]
        super Comparator
 
@@ -379,7 +379,7 @@ end
 # # ...
 # t.in_some_relation.greaters
 # ~~~
-class POSetElement[E: Object]
+class POSetElement[E]
        # The poset self belong to
        var poset: POSet[E]
 
index bb17064..858d569 100644 (file)
@@ -305,7 +305,7 @@ end
 #      # ...
 #      s.add(a)
 #      assert s.has(b)      ==  true
-interface Set[E: Object]
+interface Set[E]
        super SimpleCollection[E]
 
        redef fun has_only(item)
index 44ea5d3..ae351cf 100644 (file)
@@ -471,7 +471,7 @@ end
 # Others collections ##########################################################
 
 # A set implemented with an Array.
-class ArraySet[E: Object]
+class ArraySet[E]
        super Set[E]
 
        # The stored elements.
@@ -522,7 +522,7 @@ class ArraySet[E: Object]
 end
 
 # Iterators on sets implemented with arrays.
-private class ArraySetIterator[E: Object]
+private class ArraySetIterator[E]
        super Iterator[E]
 
        redef fun is_ok do return _iter.is_ok
index f385729..f4f218e 100644 (file)
@@ -408,7 +408,7 @@ end
 
 # A `Set` implemented with a hash table.
 # Keys of such a map cannot be null and require a working `hash` method
-class HashSet[E: Object]
+class HashSet[E]
        super Set[E]
        super HashCollection[E]
 
@@ -462,12 +462,12 @@ class HashSet[E: Object]
        redef fun new_set do return new HashSet[E]
 end
 
-private class HashSetNode[E: Object]
+private class HashSetNode[E]
        super HashNode[E]
        redef type N: HashSetNode[E]
 end
 
-private class HashSetIterator[E: Object]
+private class HashSetIterator[E]
        super Iterator[E]
        redef fun is_ok do return _node != null
 
index f9ac76f..4df80b5 100644 (file)
@@ -31,7 +31,7 @@ import hash_collection
 # Unkike theorical Disjoint-set data structures, the underling implementation is opaque
 # that makes the traditionnal `find` method unavailable for clients.
 # The methods `in_same_subset`, `to_partitions`, and their variations are offered instead.
-class DisjointSet[E: Object]
+class DisjointSet[E]
        super SimpleCollection[E]
 
        # The node in the hiearchical structure for each element