lib: promote AbstractArray#== to SequenceRead
authorJean Privat <jean@pryen.org>
Wed, 16 Oct 2013 16:58:53 +0000 (12:58 -0400)
committerJean Privat <jean@pryen.org>
Wed, 16 Oct 2013 16:58:53 +0000 (12:58 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/collection/abstract_collection.nit
lib/standard/collection/array.nit

index 536d656..cd95cc9 100644 (file)
@@ -453,6 +453,20 @@ interface SequenceRead[E]
        end
 
        redef fun iterator: IndexedIterator[E] is abstract
+
+       # Two sequences are equals if they have the same items in the same order.
+       redef fun ==(o)
+       do
+               if not o isa SequenceRead[nullable Object] or o is null then return false
+               var l = length
+               if o.length != l then return false
+               var i = 0
+               while i < l do
+                       if self[i] != o[i] then return false
+                       i += 1
+               end
+               return true
+       end
 end
 
 # Sequence are indexed collection.
index 9c34b3a..7b75ccd 100644 (file)
@@ -137,20 +137,6 @@ abstract class AbstractArrayRead[E]
        end
 
        redef fun iterator: ArrayIterator[E] do return new ArrayIterator[E](self)
-
-       # Two arrays are equals if they have the same items in the same order.
-       redef fun ==(o)
-       do
-               if not o isa AbstractArray[nullable Object] or o is null then return false
-               var l = length
-               if o.length != l then return false
-               var i = 0
-               while i < l do
-                       if self[i] != o[i] then return false
-                       i += 1
-               end
-               return true
-       end
 end
 
 # Resizable one dimension array of objects.