From: Jean Privat Date: Wed, 16 Oct 2013 16:58:53 +0000 (-0400) Subject: lib: promote AbstractArray#== to SequenceRead X-Git-Tag: v0.6.2~13 X-Git-Url: http://nitlanguage.org lib: promote AbstractArray#== to SequenceRead Signed-off-by: Jean Privat --- diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index 536d656..cd95cc9 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -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. diff --git a/lib/standard/collection/array.nit b/lib/standard/collection/array.nit index 9c34b3a..7b75ccd 100644 --- a/lib/standard/collection/array.nit +++ b/lib/standard/collection/array.nit @@ -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.