This is IndexedCollecting.h in view mode; [Download] [Up]
/* Protocol for Objective-C objects that hold elements accessible by index 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 <IndexedCollecting> protocol inherits from the <KeyedCollecting> protocol. The <IndexedCollecting> protocol defines the interface to a collection of elements that are accessible by a key that is an index, where the indeces in a collection are a contiguous series of unsigned integers beginning at 0. This is the root of the protocol heirarchy for all collections that hold their elements in some order. Elements may be accessed, inserted, replaced and removed by their index. */ #ifndef __IndexedCollecting_h_INCLUDE_GNU #define __IndexedCollecting_h_INCLUDE_GNU #include <coll/KeyedCollecting.h> /* Might COLL_NO_ELEMENT use more bits than unsigned? Is this a problem? */ #define COLL_NO_INDEX (COLL_NO_ELEMENT.unsigned_int_t) @protocol IndexedCollecting <KeyedCollecting> // ADDING; - insertObject: newObject atIndex: (unsigned)index; - insertObject: newObject before: oldObject; - insertObject: newObject after: oldObject; - appendObject: newObject; - prependObject: newObject; - appendContentsOf: (id <Collecting>)aCollection; - prependContentsOf: (id <Collecting>)aCollection; // REPLACING AND SWAPPING - replaceObjectAtIndex: (unsigned)index with: newObject; - swapAtIndeces: (unsigned)index1 : (unsigned)index2; // REMOVING - removeObjectAtIndex: (unsigned)index; - removeFirstObject; - removeLastObject; // GETTING MEMBERS BY INDEX; - objectAtIndex: (unsigned)index; - firstObject; - lastObject; // GETTING INDICES BY MEMBER; - (unsigned) indexOfObject: anObject; // TESTING; - (BOOL) includesIndex: (unsigned)index; - (BOOL) includesSameContentsInOrder: (id <IndexedCollecting>)aSequencedColl; // COPYING; - shallowCopyFrom: (unsigned)start to: (unsigned)stop; - shallowCopyReplaceFrom: (unsigned)start to: (unsigned)stop with: (id <Collecting>)replaceCollection; - shallowCopyReplaceFrom: (unsigned)start to: (unsigned)stop using: (id <Collecting>)replaceCollection; - shallowCopyInReverseAs: aCollectionClass; // ENUMERATING; - prevObject: (void**)enumState; - makeObjectsPerformInReverse: (SEL)aSel; - makeObjectsPerformInReverse: (SEL)aSel with: argObject; - withObjectsInReversePerform: (SEL)aSel in: selObject; - withObjectsInReversePerform: (SEL)aSel in: selObject with: argObject; - withObjectsInReverseCall: (void(*)(id))aFunc; - withObjectsInReverseCall: (void(*)(id))aFunc whileTrue:(BOOL *)flag; // SORTING; - sortContentsByPerforming: (SEL)aSortingSel; - sortContentsByPerforming: (SEL)aSortingSel in: selObject; - sortAddObject: newObject byPerforming: (SEL)aSortingSel; - sortAddObject: newObject byPerforming: (SEL)aSortingSel in: selObject; /* There is a separate ComparedCollecting protocol for collections that always *maintain* a compared order. But since a SequencedCollecting object *could* be sorted, we provide methods for sorting on a one-time basis, or adding an element to the collection while maintaining the sort. */ // NON-OBJECT MESSAGE NAMES; // ADDING; - appendElement: (elt)newElement; - prependElement: (elt)newElement; - insertElement: (elt)newElement atIndex: (unsigned)index; - insertElement: (elt)newElement before: (elt)oldElement; - insertElement: (elt)newElement after: (elt)oldElement; // REMOVING AND REPLACING; - (elt) replaceElementAtIndex: (unsigned)index with: (elt)newElement; // REMOVING AND REPLACING; - (elt) removeElementAtIndex: (unsigned)index; - (elt) removeFirstElement; - (elt) removeLastElement; // GETTING ELEMENTS BY INDEX; - (elt) elementAtIndex: (unsigned)index; - (elt) firstElement; - (elt) lastElement; // GETTING INDICES BY MEMBER; - (unsigned) indexOfElement: (elt)anElement; // ENUMERATING; - (BOOL) getPrevElement:(elt *)anElementPtr withEnumState: (void**)enumState; - withElementsInReverseCall: (void(*)(elt))aFunc; - withElementsInReverseCall: (void(*)(elt))aFunc whileTrue:(BOOL *)flag; // SORTING; - sortContentsByCalling: (int(*)(elt,elt))aFunc; - sortAddElement: (elt)newElement byCalling: (int(*)(elt,elt))aFunc; @end /* Most methods in the KeyedCollecting protocol that mention a key are duplicated in the IndexedCollecting protocol, with their names modified to reflect that the "key" now must be an unsigned integer, (an "index"). The programmer should be able to use either of the corresponding method names to the same effect. The new methods are provided in the IndexedCollecting protocol for: 1) Better type checking for when an unsigned int is required. 2) More intuitive method names. IndexedCollecting KeyedCollecting ---------------------------------------------------------------------- insertObject:atIndex insertObject:atKey: replaceObjectAtIndex:with: replaceObjectAtKey:with: removeObjectAtIndex: removeObjectAtKey: objectAtIndex: objectAtKey: includesIndex: includesKey: insertElement:atIndex insertElement:atKey: replaceElementAtIndex:with: replaceElementAtKey:with: removeElementAtIndex: removeElementAtKey: elementAtIndex: elementAtKey: */ #endif /* __IndexedCollecting_h_INCLUDE_GNU */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.