From dc8136dbc546650097b9bcca1c5cb0566e58feec Mon Sep 17 00:00:00 2001 From: rfm Date: Tue, 1 Feb 2011 13:51:32 +0000 Subject: [PATCH] implement missing method git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31984 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Headers/Foundation/NSPointerArray.h | 2 +- Source/NSPointerArray.m | 33 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8da20f378..3a51147c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-02-01 Richard Frith-Macdonald + + * Source/NSPointerArray.m: ([-allObjects]) implement missing method. + 2011-01-29 Stefan Bidigaray * Source/NSCalendar.m: Handle current calendar updates. diff --git a/Headers/Foundation/NSPointerArray.h b/Headers/Foundation/NSPointerArray.h index 3c96feb9f..9c873ed64 100644 --- a/Headers/Foundation/NSPointerArray.h +++ b/Headers/Foundation/NSPointerArray.h @@ -63,7 +63,7 @@ extern "C" { */ - (NSUInteger) count; -/** Initialises the receiver with the spefieifd options. +/** Initialises the receiver with the specified options. */ - (id) initWithOptions: (NSPointerFunctionsOptions)options; diff --git a/Source/NSPointerArray.m b/Source/NSPointerArray.m index 8d437a890..c9359502a 100644 --- a/Source/NSPointerArray.m +++ b/Source/NSPointerArray.m @@ -233,6 +233,39 @@ static Class concreteClass = Nil; [exception raise]; } +- (NSArray*) allObjects +{ + NSUInteger i; + NSUInteger c = 0; + + for (i = 0; i < _count; i++) + { + if (_contents[i] != 0) + { + c++; + } + } + + if (0 == c) + { + return [NSArray array]; + } + else + { + GSMutableArray *a = [GSMutableArray arrayWithCapacity: c]; + + for (i = 0; i < _count; i++) + { + if (_contents[i] != 0) + { + [a addObject: (id)_contents[i]]; + } + } + [a makeImmutableCopyOnFail: NO]; + return a; + } +} + - (void) compact { NSUInteger i = _count;