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
This commit is contained in:
Andrew McCallum 1996-02-22 16:03:55 +00:00
parent 6766050b57
commit a652d3251c

View file

@ -22,7 +22,6 @@
*/ */
#include <objects/OrderedCollection.h> #include <objects/OrderedCollection.h>
#include <objects/OrderedCollectionPrivate.h>
#include <stdio.h> #include <stdio.h>
#include <objects/Array.h> #include <objects/Array.h>
#include <objects/NSString.h> #include <objects/NSString.h>
@ -82,37 +81,31 @@
[self insertObject: newObject atIndex: 0]; [self insertObject: newObject atIndex: 0];
} }
- (void) appendObject: newObject
{
[self notImplemented: _cmd];
}
- (void) prependObject: newObject
{
[self notImplemented: _cmd];
}
- (void) appendContentsOf: (id <ConstantCollecting>) aCollection - (void) appendContentsOf: (id <ConstantCollecting>) aCollection
{ {
id o;
assert (aCollection != self); assert (aCollection != self);
/* xxx Could be more efficient. */ /* xxx Could be more efficient. */
FOR_COLLECTION(aCollection, o) FOR_COLLECTION(aCollection, o)
{ {
[self appendElement: o]; [self appendObject: o];
} }
END_FOR_COLLECTION; END_FOR_COLLECTION(aCollection);
} }
- (void) prependContentsOf: (id <ConstantCollecting>)aCollection - (void) prependContentsOf: (id <ConstantCollecting>)aCollection
{ {
id o;
assert (aCollection != self); 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]; [self prependObject: o];
} }
END_FOR_REVERSE_INDEXED_COLLECTION; END_FOR_INDEXED_COLLECTION_REVERSE(self);
} }
else else
{ {
@ -120,7 +113,7 @@
{ {
[self prependObject: o]; [self prependObject: o];
} }
END_FOR_COLLECTION; END_FOR_COLLECTION(self);
} }
} }
@ -139,7 +132,7 @@
toIndex: (unsigned)r toIndex: (unsigned)r
{ {
unsigned i ,j; unsigned i ,j;
elt x; id x;
if (p < r) if (p < r)
{ {
@ -151,10 +144,10 @@
{ {
do do
j = j - 1; j = j - 1;
while ([[self elementAtIndex:j] compare: x] > 0); while ([[self objectAtIndex: j] compare: x] > 0);
do do
i = i + 1; i = i + 1;
while ([[self elementAtIndex:i] compare: x] < 0); while ([[self objectAtIndex: i] compare: x] < 0);
if (i < j) if (i < j)
[self swapAtIndeces: i : j]; [self swapAtIndeces: i : j];
else else
@ -164,7 +157,6 @@
[self quickSortContentsFromIndex: p toIndex: j]; [self quickSortContentsFromIndex: p toIndex: j];
[self quickSortContentsFromIndex: j+1 toIndex: r]; [self quickSortContentsFromIndex: j+1 toIndex: r];
} }
return self;
} }
- (void) sortContents - (void) sortContents