lib/map: make concrete `Map.keys` and `Map.values` lazy
authorJean Privat <jean@pryen.org>
Fri, 6 Mar 2015 04:07:54 +0000 (11:07 +0700)
committerJean Privat <jean@pryen.org>
Fri, 6 Mar 2015 04:20:55 +0000 (11:20 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/collection/array.nit
lib/standard/collection/hash_collection.nit

index 1fb8581..253dd9e 100644 (file)
@@ -618,8 +618,8 @@ class ArrayMap[K, E]
                end
        end
 
-       redef var keys: RemovableCollection[K] = new ArrayMapKeys[K, E](self)
-       redef var values: RemovableCollection[E] = new ArrayMapValues[K, E](self)
+       redef var keys: RemovableCollection[K] = new ArrayMapKeys[K, E](self) is lazy
+       redef var values: RemovableCollection[E] = new ArrayMapValues[K, E](self) is lazy
 
        # O(1)
        redef fun length do return _items.length
index cdc7906..e5ff507 100644 (file)
@@ -272,8 +272,8 @@ class HashMap[K, V]
                enlarge(0)
        end
 
-       redef var keys: RemovableCollection[K] = new HashMapKeys[K, V](self)
-       redef var values: RemovableCollection[V] = new HashMapValues[K, V](self)
+       redef var keys: RemovableCollection[K] = new HashMapKeys[K, V](self) is lazy
+       redef var values: RemovableCollection[V] = new HashMapValues[K, V](self) is lazy
        redef fun has_key(k) do return node_at(k) != null
 end