From a652d3251cce6e57fc8e18186fdf477158c6f2f5 Mon Sep 17 00:00:00 2001 From: Andrew McCallum Date: Thu, 22 Feb 1996 16:03:55 +0000 Subject: [PATCH] Many fixes, continuing conversion from old IndexedCollection.m git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@963 72102866-910b-0410-8b05-ffd578937521 --- Source/OrderedCollection.m | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/Source/OrderedCollection.m b/Source/OrderedCollection.m index 0b98faf45..f61b274fb 100644 --- a/Source/OrderedCollection.m +++ b/Source/OrderedCollection.m @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -82,37 +81,31 @@ [self insertObject: newObject atIndex: 0]; } -- (void) appendObject: newObject -{ - [self notImplemented: _cmd]; -} - -- (void) prependObject: newObject -{ - [self notImplemented: _cmd]; -} - - (void) appendContentsOf: (id ) aCollection { + id o; + assert (aCollection != self); /* xxx Could be more efficient. */ FOR_COLLECTION(aCollection, o) { - [self appendElement: o]; + [self appendObject: o]; } - END_FOR_COLLECTION; + END_FOR_COLLECTION(aCollection); } - (void) prependContentsOf: (id )aCollection { + id o; + assert (aCollection != self); - if ([aCollection conformsTo: @protocol(IndexedCollecting)]) + if ([(id)aCollection conformsTo: @protocol(IndexedCollecting)]) { - FOR_REVERSE_INDEXED_COLLECTION(self, o) + FOR_INDEXED_COLLECTION_REVERSE(self, o) { [self prependObject: o]; } - END_FOR_REVERSE_INDEXED_COLLECTION; + END_FOR_INDEXED_COLLECTION_REVERSE(self); } else { @@ -120,7 +113,7 @@ { [self prependObject: o]; } - END_FOR_COLLECTION; + END_FOR_COLLECTION(self); } } @@ -139,7 +132,7 @@ toIndex: (unsigned)r { unsigned i ,j; - elt x; + id x; if (p < r) { @@ -151,10 +144,10 @@ { do j = j - 1; - while ([[self elementAtIndex:j] compare: x] > 0); + while ([[self objectAtIndex: j] compare: x] > 0); do i = i + 1; - while ([[self elementAtIndex:i] compare: x] < 0); + while ([[self objectAtIndex: i] compare: x] < 0); if (i < j) [self swapAtIndeces: i : j]; else @@ -164,7 +157,6 @@ [self quickSortContentsFromIndex: p toIndex: j]; [self quickSortContentsFromIndex: j+1 toIndex: r]; } - return self; } - (void) sortContents