~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Source/NSArray.m

Tags: upstream-1.11.2
ImportĀ upstreamĀ versionĀ 1.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
   You should have received a copy of the GNU Library General Public
25
25
   License along with this library; if not, write to the Free
26
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
26
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
27
27
 
28
28
   <title>NSArray class reference</title>
29
 
   $Date: 2005/02/22 11:22:43 $ $Revision: 1.144 $
 
29
   $Date: 2005/11/28 15:41:32 $ $Revision: 1.152 $
30
30
   */
31
31
 
32
32
#include "config.h"
53
53
extern BOOL     GSMacOSXCompatiblePropertyLists(void);
54
54
extern void     GSPropertyListMake(id,NSDictionary*,BOOL,BOOL,unsigned,id*);
55
55
 
56
 
@class NSArrayEnumerator;
57
 
@class NSArrayEnumeratorReverse;
 
56
@interface NSArrayEnumerator : NSEnumerator
 
57
{
 
58
  NSArray       *array;
 
59
  unsigned      pos;
 
60
  IMP           get;
 
61
  unsigned      (*cnt)(NSArray*, SEL);
 
62
}
 
63
- (id) initWithArray: (NSArray*)anArray;
 
64
@end
 
65
@interface NSArrayEnumeratorReverse : NSArrayEnumerator
 
66
@end
 
67
 
 
68
 
58
69
 
59
70
@class  GSArray;
 
71
@interface GSArray : NSObject   // Help the compiler
 
72
@end
60
73
@class  GSInlineArray;
 
74
@interface GSInlineArray : NSObject     // Help the compiler
 
75
@end
61
76
@class  GSMutableArray;
 
77
@interface GSMutableArray : NSObject    // Help the compiler
 
78
@end
62
79
@class  GSPlaceholderArray;
 
80
@interface GSPlaceholderArray : NSObject        // Help the compiler
 
81
@end
63
82
 
64
83
static Class NSArrayClass;
65
84
static Class GSArrayClass;
193
212
 
194
213
/**
195
214
 * Returns an autoreleased array based upon the file.  The new array is
196
 
 * created using +allocWithZone: and initialised using the
197
 
 * -initWithContentsOfFile: method. See the documentation for those
 
215
 * created using [NSObject+allocWithZone:] and initialised using the
 
216
 * [NSArray-initWithContentsOfFile:] method. See the documentation for those
198
217
 * methods for more detail.
199
218
 */
200
219
+ (id) arrayWithContentsOfFile: (NSString*)file
207
226
}
208
227
 
209
228
/**
210
 
 * Returns an autoreleased array from the contenta of aURL.  The new array is
211
 
 * created using +allocWithZone: and initialised using the
 
229
 * Returns an autoreleased array from the contents of aURL.  The new array is
 
230
 * created using [NSObject+allocWithZone:] and initialised using the
212
231
 * -initWithContentsOfURL: method. See the documentation for those
213
232
 * methods for more detail.
214
233
 */
322
341
 
323
342
/**
324
343
 * Returns YES if anObject belongs to self. No otherwise.<br />
325
 
 * The -isEqual: method of anObject is used to test for equality.
 
344
 * The [NSObject-isEqual:] method of anObject is used to test for equality.
326
345
 */
327
346
- (BOOL) containsObject: (id)anObject
328
347
{
476
495
 
477
496
/**
478
497
 * Returns the index of the first object found in the receiver
479
 
 * which is equal to anObject (using anObject's -isEqual: method).
 
498
 * which is equal to anObject (using anObject's [NSObject-isEqual:] method).
480
499
 * Returns NSNotFound on failure.
481
500
 */
482
501
- (unsigned) indexOfObject: (id)anObject
499
518
 
500
519
/**
501
520
 * Returns the index of the first object found in aRange of receiver
502
 
 * which is equal to anObject (using anObject's -isEqual: method).
 
521
 * which is equal to anObject (using anObject's [NSObject-isEqual:] method).
503
522
 * Returns NSNotFound on failure.
504
523
 */
505
524
- (unsigned) indexOfObject: (id)anObject inRange: (NSRange)aRange
722
741
 * which must contain an array in property-list format.
723
742
 * </p>
724
743
 * <p>In GNUstep, the property-list format may be either the OpenStep
725
 
 * format (ASCII data), or the MacOS-X format (URF8 XML data) ... this
 
744
 * format (ASCII data), or the MacOS-X format (UTF8 XML data) ... this
726
745
 * method will recognise which it is.
727
746
 * </p>
728
747
 * <p>If there is a failure to load the URL for any reason, the receiver
1251
1270
      unsigned          count = [self count];
1252
1271
      volatile id       object = nil;
1253
1272
 
1254
 
      results = [NSMutableArray array];
 
1273
      results = [NSMutableArray arrayWithCapacity: count];
1255
1274
 
1256
1275
      for (i = 0; i < count; i++)
1257
1276
        {
1416
1435
}
1417
1436
 
1418
1437
/**
1419
 
 * Creates an autoreleased mutable array anble to store at least numItems.
 
1438
 * Creates an autoreleased mutable array able to store at least numItems.
1420
1439
 * See the -initWithCapacity: method.
1421
1440
 */
1422
1441
+ (id) arrayWithCapacity: (unsigned)numItems
1492
1511
}
1493
1512
 
1494
1513
/**
1495
 
 * Removes all occurrences of anObject (found by the -isEqual: method
 
1514
 * Removes all occurrences of anObject (found by the [NSObject-isEqual:] method
1496
1515
 * of anObject) aRange in the receiver.
1497
1516
 */
1498
1517
- (void) removeObject: (id)anObject inRange: (NSRange)aRange
1549
1568
}
1550
1569
 
1551
1570
/**
1552
 
 * Removes all occurrances of anObject (found by pointer equality)
 
1571
 * Removes all occurrences of anObject (found by pointer equality)
1553
1572
 * from aRange in the receiver.
1554
1573
 */
1555
1574
- (void) removeObjectIdenticalTo: (id)anObject inRange: (NSRange)aRange
1592
1611
}
1593
1612
 
1594
1613
/**
1595
 
 * Removes all occurrences of anObject (found by anObjects -isEqual: method)
1596
 
 * from the receiver.
 
1614
 * Removes all occurrences of anObject (found by anObject's
 
1615
 * [NSObject-isEqual:] method) from the receiver.
1597
1616
 */
1598
1617
- (void) removeObject: (id)anObject
1599
1618
{
1631
1650
              (*rem)(self, remSel, i);
1632
1651
            }
1633
1652
        }
1634
 
#ifndef GS_WITH_GC
 
1653
#if GS_WITH_GC == 0
1635
1654
      if (rem != 0)
1636
1655
        {
1637
1656
          RELEASE(anObject);
1678
1697
 
1679
1698
/**
1680
1699
 * Sets the contents of the receiver to be identical to the contents
1681
 
 * of othrArray.
 
1700
 * of otherArray.
1682
1701
 */
1683
1702
- (void) setArray: (NSArray *)otherArray
1684
1703
{
1747
1766
 
1748
1767
/**
1749
1768
 * Removes from the receiver, all the objects present in otherArray,
1750
 
 * as determined by using the -isEqual: method.
 
1769
 * as determined by using the [NSObject-isEqual:] method.
1751
1770
 */
1752
1771
- (void) removeObjectsInArray: (NSArray*)otherArray
1753
1772
{
1898
1917
}
1899
1918
@end
1900
1919
 
1901
 
@interface NSArrayEnumerator : NSEnumerator
1902
 
{
1903
 
  NSArray       *array;
1904
 
  unsigned      pos;
1905
 
  IMP           get;
1906
 
  unsigned      (*cnt)(NSArray*, SEL);
1907
 
}
1908
 
- (id) initWithArray: (NSArray*)anArray;
1909
 
@end
1910
 
 
1911
1920
@implementation NSArrayEnumerator
1912
1921
 
1913
1922
- (id) initWithArray: (NSArray*)anArray
1945
1954
 
1946
1955
@end
1947
1956
 
1948
 
@interface NSArrayEnumeratorReverse : NSArrayEnumerator
1949
 
@end
1950
 
 
1951
1957
@implementation NSArrayEnumeratorReverse
1952
1958
 
1953
1959
- (id) initWithArray: (NSArray*)anArray