lib/hash: HashCollection::N become a virtual type
authorJean Privat <jean@pryen.org>
Tue, 18 Nov 2014 21:24:22 +0000 (16:24 -0500)
committerJean Privat <jean@pryen.org>
Wed, 19 Nov 2014 02:02:17 +0000 (21:02 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/hash_debug.nit
lib/standard/collection/hash_collection.nit

index b618729..8426097 100644 (file)
@@ -121,7 +121,7 @@ do
        super
 end
 
-redef class HashCollection[K,N]
+redef class HashCollection[K]
        redef fun node_at_idx(i,k)
        do
                sys.gt_count += 1
index 8e27c80..92b8d5c 100644 (file)
@@ -16,7 +16,8 @@ module hash_collection
 import array
 
 # A HashCollection is an array of HashNode[K] indexed by the K hash value
-private abstract class HashCollection[K: Object, N: HashNode[Object]]
+private abstract class HashCollection[K: Object]
+       type N: HashNode[K]
 
        private var array: nullable NativeArray[nullable N] = null # Used to store items
        private var capacity: Int = 0 # Size of _array
@@ -202,7 +203,9 @@ end
 # Keys of such a map cannot be null and require a working `hash` method
 class HashMap[K: Object, V]
        super Map[K, V]
-       super HashCollection[K, HashMapNode[K, V]]
+       super HashCollection[K]
+
+       redef type N: HashMapNode[K, V] is fixed
 
        redef fun [](key)
        do
@@ -388,7 +391,9 @@ end
 # Keys of such a map cannot be null and require a working `hash` method
 class HashSet[E: Object]
        super Set[E]
-       super HashCollection[E, HashSetNode[E]]
+       super HashCollection[E]
+
+       redef type N: HashSetNode[E] is fixed
 
        redef fun length do return _the_length