From ebab8140a0e8f8513c8c8c876c5d19ad84fa3f36 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 16 Oct 2013 12:58:53 -0400 Subject: [PATCH] lib: promote AbstractArray#== to SequenceRead Signed-off-by: Jean Privat --- lib/standard/collection/abstract_collection.nit | 14 ++++++++++++++ lib/standard/collection/array.nit | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) 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. -- 1.7.9.5