1994-11-04 16:29:24 +00:00
|
|
|
/* Protocol for Objective-C objects that hold collections of elements.
|
1996-02-22 15:11:43 +00:00
|
|
|
Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
1996-02-22 15:11:43 +00:00
|
|
|
Created: May 1993
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
This file is part of the GNU Objective C Class 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 enumerated through various
|
|
|
|
filters. Elements may be objects, or any C type included in the
|
|
|
|
"elt" union given in elt.h, but all elements of a collection must be of
|
|
|
|
the same C type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __Collecting_h_INCLUDE_GNU
|
|
|
|
#define __Collecting_h_INCLUDE_GNU
|
|
|
|
|
|
|
|
#include <objects/stdobjects.h>
|
1996-02-22 15:11:43 +00:00
|
|
|
#include <objects/Coding.h>
|
|
|
|
#include <objects/Invoking.h>
|
|
|
|
#include <objects/Enumerating.h>
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1995-04-08 17:04:07 +00:00
|
|
|
@protocol ConstantCollecting
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
// INITIALIZING;
|
|
|
|
- init;
|
1996-02-22 15:11:43 +00:00
|
|
|
- initWithObjects: (id*)objc count: (unsigned)c;
|
|
|
|
- initWithObjects: firstObject, ...;
|
|
|
|
- initWithObjects: firstObject rest: (va_list)ap;
|
1995-04-09 01:37:46 +00:00
|
|
|
- initWithContentsOf: (id <ConstantCollecting>)aCollection;
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1996-02-22 15:11:43 +00:00
|
|
|
// QUERYING COUNTS;
|
1994-11-04 16:29:24 +00:00
|
|
|
- (BOOL) isEmpty;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (unsigned) count;
|
|
|
|
- (BOOL) containsObject: anObject;
|
|
|
|
- (unsigned) occurrencesOfObject: anObject;
|
|
|
|
|
|
|
|
// COMPARISON WITH OTHER COLLECTIONS;
|
1995-04-09 01:37:46 +00:00
|
|
|
- (BOOL) isSubsetOf: (id <ConstantCollecting>)aCollection;
|
|
|
|
- (BOOL) isDisjointFrom: (id <ConstantCollecting>)aCollection;
|
1994-11-04 16:29:24 +00:00
|
|
|
- (BOOL) isEqual: anObject;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (int) compare: anObject;
|
1995-04-09 01:37:46 +00:00
|
|
|
- (BOOL) contentsEqual: (id <ConstantCollecting>)aCollection;
|
1996-02-22 15:11:43 +00:00
|
|
|
|
|
|
|
// PROPERTIES OF CONTENTS;
|
|
|
|
- (BOOL) trueForAllObjectsByInvoking: (id <Invoking>)anInvocation;
|
|
|
|
- (BOOL) trueForAnyObjectsByInvoking: (id <Invoking>)anInvocation;
|
|
|
|
- detectObjectByInvoking: (id <Invoking>)anInvocation;
|
1994-11-04 16:29:24 +00:00
|
|
|
- maxObject;
|
|
|
|
- minObject;
|
|
|
|
|
|
|
|
// ENUMERATING
|
1996-02-22 15:11:43 +00:00
|
|
|
- (id <Enumerating>) objectEnumerator;
|
|
|
|
- (void) withObjectsInvoke: (id <Invoking>)anInvocation;
|
|
|
|
- (void) withObjectsInvoke: (id <Invoking>)anInvocation whileTrue:(BOOL *)flag;
|
|
|
|
- (void) makeObjectsPerform: (SEL)aSel;
|
|
|
|
- (void) makeObjectsPerform: (SEL)aSel withObject: argObject;
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
// FILTERED ENUMERATING;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (void) withObjectsTrueByInvoking: (id <Invoking>)testInvocation
|
|
|
|
invoke: (id <Invoking>)anInvocation;
|
|
|
|
- (void) withObjectsFalseByInvoking: (id <Invoking>)testInvocation
|
|
|
|
invoke: (id <Invoking>)anInvocation;
|
|
|
|
- (void) withObjectsTransformedByInvoking: (id <Invoking>)transInvocation
|
|
|
|
invoke: (id <Invoking>)anInvocation;
|
|
|
|
|
|
|
|
// LOW-LEVEL ENUMERATING;
|
|
|
|
- (void*) newEnumState;
|
|
|
|
- nextObjectWithEnumState: (void**)enumState;
|
|
|
|
- (void) freeEnumState: (void**)enumState;
|
|
|
|
|
|
|
|
// COPYING;
|
|
|
|
- allocCopy;
|
1994-11-04 16:29:24 +00:00
|
|
|
- emptyCopy;
|
1995-03-23 03:35:01 +00:00
|
|
|
- emptyCopyAs: (Class)aCollectionClass;
|
1994-11-04 16:29:24 +00:00
|
|
|
- shallowCopy;
|
1995-03-23 03:35:01 +00:00
|
|
|
- shallowCopyAs: (Class)aCollectionClass;
|
1994-11-04 16:29:24 +00:00
|
|
|
- copy;
|
1995-03-23 03:35:01 +00:00
|
|
|
- copyAs: (Class)aCollectionClass;
|
1994-11-04 16:29:24 +00:00
|
|
|
- species;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
1995-04-08 17:04:07 +00:00
|
|
|
|
|
|
|
@protocol Collecting <ConstantCollecting>
|
|
|
|
|
|
|
|
// ADDING;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (void) addObject: newObject;
|
|
|
|
- (void) addObjectIfAbsent: newObject;
|
|
|
|
- (void) addContentsOf: (id <ConstantCollecting>)aCollection;
|
|
|
|
- (void) addContentsIfAbsentOf: (id <ConstantCollecting>)aCollection;
|
|
|
|
- (void) addWithObjects: (id*)objc count: (unsigned)c;
|
|
|
|
- (void) addObjects: firstObject, ...;
|
|
|
|
- (void) addObjects: firstObject rest: (va_list)ap;
|
1995-04-08 17:04:07 +00:00
|
|
|
|
|
|
|
// REMOVING;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (void) removeObject: oldObject;
|
|
|
|
- (void) removeAllOccurrencesOfObject: oldObject;
|
|
|
|
- (void) removeContentsIn: (id <ConstantCollecting>)aCollection;
|
|
|
|
- (void) removeContentsNotIn: (id <ConstantCollecting>)aCollection;
|
|
|
|
- (void) uniqueContents;
|
|
|
|
- (void) empty;
|
1995-04-08 17:04:07 +00:00
|
|
|
|
|
|
|
// REPLACING;
|
1996-02-22 15:11:43 +00:00
|
|
|
- (void) replaceObject: oldObject withObject: newObject;
|
|
|
|
- (void) replaceAllOccurrencesOfObject: oldObject withObject: newObject;
|
1995-04-08 17:04:07 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
1996-02-22 15:11:43 +00:00
|
|
|
#define NO_OBJECT nil
|
|
|
|
|
1994-11-04 16:29:24 +00:00
|
|
|
#endif /* __Collecting_h_INCLUDE_GNU */
|