mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Add missing methods
Array: Implement -indexOfObject: and -indexOfObjectIdenticalTo:
This commit is contained in:
parent
4968b65b2f
commit
061f56ea2d
2 changed files with 99 additions and 5 deletions
|
@ -142,6 +142,45 @@
|
|||
#endif
|
||||
//\}
|
||||
|
||||
///\name Finding objects
|
||||
//\{
|
||||
/**
|
||||
Returns the lowest index of an object equal to \a anObject.
|
||||
|
||||
If no object is equal, returns #NotFound.
|
||||
*/
|
||||
- (unsigned) indexOfObject: (id)anObject;
|
||||
|
||||
#if 0
|
||||
/**
|
||||
Returns the lowest index, within the range \a aRange, of an object equal
|
||||
to \a anObject.
|
||||
|
||||
If no object is equal, returns #NotFound.
|
||||
*/
|
||||
- (unsigned) indexOfObject: (id)anObject
|
||||
inRange: (Range)aRange;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Returns the lowest index of an object with the same address as \a anObject.
|
||||
|
||||
Returns #NotFound if \a anObject is not found within the array.
|
||||
*/
|
||||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject;
|
||||
|
||||
#if 0
|
||||
/**
|
||||
Returns the lowest index, within the range \a aRange, of an object with
|
||||
the same address as \a anObject.
|
||||
|
||||
Returns #NotFound if \a anObject is not found within the range.
|
||||
*/
|
||||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject
|
||||
inRange: (Range)aRange;
|
||||
#endif
|
||||
//\}
|
||||
|
||||
///\name Adding objects
|
||||
//\{
|
||||
|
||||
|
|
|
@ -148,16 +148,16 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (unsigned) count
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
- (BOOL) containsObject: (id)anObject
|
||||
{
|
||||
return [self indexOfObject: anObject] ? YES : NO;
|
||||
}
|
||||
|
||||
- (unsigned) count
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
- (id) objectAtIndex: (unsigned)index
|
||||
{
|
||||
if (index >= count) // FIXME: need exceptions
|
||||
|
@ -171,6 +171,61 @@
|
|||
return [self objectAtIndex: [self count] - 1];
|
||||
}
|
||||
|
||||
/*
|
||||
Finding Objects
|
||||
*/
|
||||
- (unsigned) indexOfObject: (id)anObject
|
||||
{
|
||||
local unsigned i;
|
||||
|
||||
for (i = 0; i < [self count]; i++) {
|
||||
if ([[self objectAtIndex: i] isEqual: anObject])
|
||||
return i;
|
||||
}
|
||||
return NotFound;
|
||||
}
|
||||
|
||||
#if 0
|
||||
- (unsigned) indexOfObject: (id)anObject
|
||||
inRange: (Range)range;
|
||||
{
|
||||
local unsigned i;
|
||||
local unsigned end = range.location + range.length;
|
||||
|
||||
for (i = range.location; i < end && i < [self count]; i++) {
|
||||
if ([[self objectAtIndex: i] isEqual: anObject])
|
||||
return i;
|
||||
}
|
||||
return NotFound;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject
|
||||
{
|
||||
local unsigned i;
|
||||
|
||||
for (i = 0; i < [self count]; i++) {
|
||||
if ([self objectAtIndex: i] == anObject)
|
||||
return i;
|
||||
}
|
||||
return NotFound;
|
||||
}
|
||||
|
||||
#if 0
|
||||
- (unsigned) indexOfObjectIdenticalTo: (id)anObject
|
||||
inRange: (Range)range;
|
||||
{
|
||||
local unsigned i;
|
||||
local unsigned end = range.location + range.length;
|
||||
|
||||
for (i = range.location; i < end && i < [self count]; i++) {
|
||||
if ([self objectAtIndex: i] == anObject)
|
||||
return i;
|
||||
}
|
||||
return NotFound;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Adding objects
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue