From: Jean Privat Date: Tue, 18 Nov 2014 21:24:22 +0000 (-0500) Subject: lib/hash: HashCollection::N become a virtual type X-Git-Tag: v0.6.11~24^2~3 X-Git-Url: http://nitlanguage.org lib/hash: HashCollection::N become a virtual type Signed-off-by: Jean Privat --- diff --git a/lib/hash_debug.nit b/lib/hash_debug.nit index b618729..8426097 100644 --- a/lib/hash_debug.nit +++ b/lib/hash_debug.nit @@ -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 diff --git a/lib/standard/collection/hash_collection.nit b/lib/standard/collection/hash_collection.nit index 8e27c80..92b8d5c 100644 --- a/lib/standard/collection/hash_collection.nit +++ b/lib/standard/collection/hash_collection.nit @@ -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