This is Collecting.h in view mode; [Download] [Up]
/* Protocol for Objective-C objects that hold collections of elements.
Copyright (C) 1993 R. Andrew McCallum <mccallum@cs.rochester.edu>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
This file is part of the GNU Objective-C Collection library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* The <Collecting> protocol is root of the collection protocol heirarchy.
The <Collecting> protocol defines the most general interface to a
collection of elements. Elements can be added, removed, and replaced.
The contents can be tested, enumerated, and copied with various
modifications. Elements may be objects, or any C type included in the
"elt" union given below, but all elements of a collection must be of
the same C type.
*/
#ifndef __Collecting_h_INCLUDE_GNU
#define __Collecting_h_INCLUDE_GNU
#include <objc/Object.h>
#include <limits.h>
typedef union _elt
{
id id_t;
SEL SEL_t;
int int_t;
unsigned int unsigned_int_t;
char char_t; /* remove these smaller ones?
Not now handled anyway. */
unsigned char unsigned_char_t;
short int short_int_t;
unsigned short int unsigned_short_int_t;
long int long_int_t;
unsigned long int unsigned_long_int_t;
float float_t;
const void *void_ptr_t;
char *char_ptr_t;
} elt;
/* defined in Collection.m as (~0L) */
extern const elt COLL_NO_ELEMENT;
#define COLL_NO_OBJECT (COLL_NO_ELEMENT.id_t)
@protocol Collecting
// INITIALIZING AND FREEING;
- init;
- initWith: (unsigned)count, ...;
- free;
- freeContents;
// ADDING;
- addObject: newObject;
- addObjectIfAbsent: newObject;
- addContentsOf: (id <Collecting>)aCollection;
- addContentsOfIfAbsent: (id <Collecting>)aCollection;
- addCount: (unsigned)count, ...;
// REMOVING AND REPLACING;
- removeObject: oldObject;
- removeAllOccurrencesOfObject: oldObject;
- replaceObject: oldObject with: newObject;
- replaceAllOccurrencesOfObject: oldObject with: newObject;
- removeContentsIn: (id <Collecting>)aCollection;
- removeContentsNotIn: (id <Collecting>)aCollection;
- uniqueContents;
- empty;
// TESTING;
- (BOOL) isEmpty;
- (BOOL) includesObject: anObject;
- (BOOL) includesSubsetOf: (id <Collecting>)aCollection;
- (BOOL) includesSameContents: (id <Collecting>)aCollection;
- (BOOL) isEqual: anObject;
- (BOOL) isDisjointFrom: (id <Collecting>)aCollection;
- (unsigned) count;
- (unsigned) occurrencesOfObject: anObject;
- (BOOL) containsObjects;
- (BOOL) trueForAllByPerforming: (SEL)aBoolSel;
- (BOOL) trueForAllByPerforming: (SEL)aBoolSel with: argObject;
- (BOOL) trueForAllByPerforming: (SEL)aBoolSel in: selObject;
- (BOOL) trueForAllByPerforming: (SEL)aBoolSel in: selObject with: argObject;
- (BOOL) trueForAnyByPerforming: (SEL)aBoolSel;
- (BOOL) trueForAnyByPerforming: (SEL)aBoolSel with: argObject;
- (BOOL) trueForAnyByPerforming: (SEL)aBoolSel in: selObject;
- (BOOL) trueForAnyByPerforming: (SEL)aBoolSel in: selObject with: argObject;
// ENUMERATING
- nextObject: (void**)enumState;
- makeObjectsPerform: (SEL)aSel;
- makeObjectsPerform: (SEL)aSel with: argObject;
- withObjectsPerform: (SEL)aSel in: selObject;
- withObjectsPerform: (SEL)aSel in: selObject with: argObject;
- withObjectsCall: (void(*)(id))aFunc;
- withObjectsCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag;
// COPYING
- shallowCopy;
- shallowCopyAs: (id <Collecting>)aCollectionClass;
- emptyCopyAs: aCollectionClass;
- deepen;
- species;
// COPYING ENUMERATORS;
- shallowCopySelectByPerforming: (SEL)aBoolSel in: selObject;
- shallowCopySelectByPerforming: (SEL)aBoolSel in: selObject with: argObject;
- shallowCopySelectByPerforming: (SEL)aBoolSel;
- shallowCopySelectByPerforming: (SEL)aBoolSel with: argObject;
- shallowCopyRejectByPerforming: (SEL)aBoolSel in: selObject;
- shallowCopyRejectByPerforming: (SEL)aBoolSel in: selObject with: argObject;
- shallowCopyRejectByPerforming: (SEL)aBoolSel;
- shallowCopyRejectByPerforming: (SEL)aBoolSel with: argObject;
- shallowCopyCollectByPerforming: (SEL)aSel in: selObject;
- shallowCopyCollectByPerforming: (SEL)aSel in: selObject with: argObject;
- shallowCopyCollectByPerforming: (SEL)aSel;
- shallowCopyCollectByPerforming: (SEL)aSel with: argObject;
// NON-COPYING ENUMERATORS;
- detectByPerforming: (SEL)aBoolSel;
- detectByPerforming: (SEL)aBoolSel with: argObject;
- detectByPerforming: (SEL)aBoolSel in: selObject;
- detectByPerforming: (SEL)aBoolSel in: selObject with: argObject;
- detectObjectByCalling: (BOOL(*)(id))aFunc;
- inject: initialArgObject byPerforming: (SEL)aSel in: selObject;
- maxByPerforming: (SEL)aSortingSel;
- maxByPerforming: (SEL)aSortingSel in: selObject;
- maxObjectByCalling: (int(*)(id,id))aFunc;
- minByPerforming: (SEL)aSortingSel;
- minByPerforming: (SEL)aSortingSel in: selObject;
- minObjectByCalling: (int(*)(id,id))aFunc;
// ARCHIVING... something like this?;
/****
- readFrom:aStream;
- readContentsFrom:aStream;
- writeOn:aStream;
- writeContentsOn:aStream;
- printOn:aStream;
****/
// NON-OBJECT ELEMENT METHOD NAMES;
// INITIALIZING;
- initDescription:(const char *)type;
- initDescription:(const char *)type with: (unsigned)count, ...;
// ADDING;
- addElement: (elt)newElement;
- addElementIfAbsent: (elt)newElement;
// REMOVING AND REPLACING;
- (elt) removeElement: (elt)oldElement;
- (elt) removeAllOccurrencesOfElement: (elt)oldElement;
- (elt) replaceElement: (elt)oldElement with: (elt)newElement;
- (elt) replaceAllOccurrencesOfElement: (elt)oldElement with: (elt)newElement;
// TESTING;
- (BOOL) includesElement: (elt)anElement;
- (unsigned) occurrencesOfElement: (elt)anElement;
- (BOOL) trueForAllByCalling: (BOOL(*)(elt))aFunc;
- (BOOL) trueForAnyByCalling: (BOOL(*)(elt))aFunc;
- (const char *) contentsDescription;
// ENUMERATING;
- (BOOL) getNextElement:(elt *)anElementPtr withEnumState: (void**)enumState;
- withElementsCall: (void(*)(elt))aFunc;
- withElementsCall: (void(*)(elt))aFunc whileTrue: (BOOL*)flag;
// COPYING ENUMERATORS;
- shallowCopySelectByCalling: (BOOL(*)(elt))aFunc;
- shallowCopyRejectByCalling: (BOOL(*)(elt))aFunc;
- shallowCopyCollectByCalling: (elt (*)(elt))aFunc;
// NON-COPYING ENUMERATORS;
- (elt) detectElementByCalling: (BOOL(*)(elt))aFunc;
- (elt) maxElementByCalling: (int(*)(elt,elt))aFunc;
- (elt) minElementByCalling: (int(*)(elt,elt))aFunc;
- inject: (void *)initialData byCalling: (void* (*)(void*,elt))aFunc;
@end
#endif /* __Collecting_h_INCLUDE_GNU */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.