lib: remove some depreciated methods in Map
authorJean Privat <jean@pryen.org>
Fri, 10 Feb 2012 16:44:04 +0000 (11:44 -0500)
committerJean Privat <jean@pryen.org>
Mon, 13 Feb 2012 19:04:52 +0000 (14:04 -0500)
Known clients are updated.

The only remaining depreciated method is has_key.

Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/collection/abstract_collection.nit
src/metamodel/partial_order.nit
tests/test_map.nit

index b164060..3a2b25b 100644 (file)
@@ -270,18 +270,6 @@ interface MapRead[K: Object, E]
 
        # Number of items in the collection.
        fun length: Int is abstract
-
-       # Depreciated alias for `values.has'
-       fun has(item: E): Bool do return self.values.has(item)
-
-       # Depreciated alias for `values.has_only'
-       fun has_only(item: E): Bool do return self.values.has_only(item)
-
-       # Depreciated alias for `values.count'
-       fun count(item: E): Int do return self.values.count(item)
-
-       # Depreciated alias for `values.first'
-       fun first: E do return self.values.first
 end
 
 # Maps are associative collections: `key' -> `item'.
@@ -301,9 +289,6 @@ interface Map[K: Object, E]
        # Set the`item' at `key'.
        fun []=(key: K, item: E) is abstract
 
-       # Depreciated alias for `keys.remove`
-       fun remove_at(key: K) do keys.remove(key)
-
        # Add each (key,value) of `map' into `self'.
        # If a same key exists in `map' and `self', then the value in self is discarded.
        fun recover_with(map: Map[K, E])
@@ -318,12 +303,6 @@ interface Map[K: Object, E]
        # Remove all items
        fun clear is abstract
 
-       # Depreciated alias for `values.remove`
-       fun remove(item: E) do values.remove(item)
-
-       # Depreciated alias for `values.remove_all`
-       fun remove_all(item: E) do values.remove_all(item)
-
        redef fun values: RemovableCollection[E] is abstract
 
        redef fun keys: RemovableCollection[E] is abstract
index 91b8f43..ff71f47 100644 (file)
@@ -40,7 +40,7 @@ class PartialOrder[E: Object]
 
        redef fun has(e) do return _elements.has_key(e)
 
-       redef fun has_only(e) do return _elements.length == 1 and _elements.first == e
+       redef fun has_only(e) do return _elements.length == 1 and _elements.values.first == e
 
        redef fun count(e)
        do
index fd9e1b3..e356e0f 100644 (file)
@@ -26,9 +26,9 @@ do
        print(h.has_key(1))
        print(h.has_key(2))
        print(not h.has_key(3))
-       print(not h.has(2))
-       print(h.has(4))
-       print(h.has(20))
+       print(not h.values.has(2))
+       print(h.values.has(4))
+       print(h.values.has(20))
        print(h.length)
        var s = 24
        for x in h.values do
@@ -61,7 +61,7 @@ do
        i = nb * 2
        while i >= 0 do
                if (i % 3 != 0) then
-                       h.remove(i)
+                       h.values.remove(i)
                end
                i = i - 1
        end
@@ -89,14 +89,14 @@ do
        print("* start:")
        print(m.is_empty)
        print(m.length == 0)
-       print(m.has_only("vert"))
-       print(m.count("vert") == 0)
+       print(m.values.has_only("vert"))
+       print(m.values.count("vert") == 0)
        m["blue"] = "vert"
        print(not m.is_empty)
-       print(m.has_only("vert"))
-       print(m.count("vert") == 1)
+       print(m.values.has_only("vert"))
+       print(m.values.count("vert") == 1)
        m["red"] = "rouge"
-       print(not m.has_only("vert"))
+       print(not m.values.has_only("vert"))
        m["blue"] = "bleu"
        print(m.length == 2)
 
@@ -109,28 +109,28 @@ do
        m["grey"] = "gris"
        m["white"] = "blanc"
        print(m.length == 9)
-       print(m.count("vert") == 0)
-       print(m.count("gris") == 2)
+       print(m.values.count("vert") == 0)
+       print(m.values.count("gris") == 2)
        print(m["blue"] == "bleu")
-       print(not m.has("vert"))
-       print(m.has("bleu"))
-       print(not m.has("blue"))
+       print(not m.values.has("vert"))
+       print(m.values.has("bleu"))
+       print(not m.values.has("blue"))
        print(m.has_key("blue"))
        print(not m.has_key("green"))
        print(not m.has_key("vert"))
        print(m.values.join(", "))
 
        print("* remove:")
-       print(m.count("rose") == 1)
-       m.remove("rose")
+       print(m.values.count("rose") == 1)
+       m.values.remove("rose")
        print(m.length == 8)
-       print(m.count("rose") == 0)
-       m.remove_all("gris")
+       print(m.values.count("rose") == 0)
+       m.values.remove_all("gris")
        print(m.length == 6)
-       print(m.count("gris") == 0)
-       m.remove_at("blue")
+       print(m.values.count("gris") == 0)
+       m.keys.remove("blue")
        print(m.length == 5)
-       print(m.count("bleu") == 0)
+       print(m.values.count("bleu") == 0)
        print(m.values.join(", "))
        m.clear
        print(m.is_empty)