mccallum@gnu.ai.mit.edu
)Version: 1.55
Date: 2005/02/22 11:22:44
Copyright: (C) 1995, 1996, 1998 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSSet.h
Standards:
- MacOS-X
- OpenStep
- GNUstep
The NSCountedSet
class is used to maintain
a set of objects where the number of times each object
has been added (without a corresponding removal) is
kept track of.
In GNUstep, the purge
and
unique
methods are provided to make use
of a counted set for uniquing objects easier.
Method summary
Returns the number of times that an object that is equal to the specified object (as determined by the [-isEqual:] method) has been added to the set and not removed from it.
- Declared in:
- Foundation/NSSet.h
Standards:
- MacOS-X
- OpenStep
- GNUstep
Mutable version of NSSet .
Method summaryNew autoreleased instance with given capacity.
Adds anObject to the set.
The object
is retained by the set.
Adds all the objects in the array to the receiver.
Initialises a newly allocated set to contain no
objects but to have space available to hold the
specified number of items.
Additions of
items to a set initialised with an appropriate
capacity will be more efficient than addition of
items otherwise.
Calls
-init
(which does nothing but maintain MacOS-X
compatibility), and needs to be
re-implemented in subclasses in order to
have all other initialisers work.
Removes from the receiver all the objects it contains which are not also in other.
Removes from the receiver all the objects that are in other.
Removes all objects from the receiver.
Removes the anObject from the receiver.
Removes all objects from the receiver then adds the objects from other. If the receiver is other, the method has no effect.
* Adds all the objects from other to the receiver.
- Declared in:
- Foundation/NSSet.h
- Conforms to:
- NSCoding
- NSCopying
- NSMutableCopying
Standards:
- MacOS-X
- OpenStep
- GNUstep
NSSet
maintains an unordered collection
of unique objects (according to
[NSObject -isEqual:]
). When a duplicate object is added to the set, it
replaces its old copy.
New autoreleased empty set.
New set containing (unique elements of) objects.
New set containing single object anObject.
New set with objects in given nil-terminated list.
New set containing (unique elements of) objects.
Copy constructor.
Return array of all objects in set. Order is undefined.
Return an arbitrary object from set, or
nil
if this is empty set.
Return whether set contains an object equal to this one according to [NSObject -isEqual:] .
Returns the number of objects stored in the set.
Returns listing of objects in set.
Returns listing of objects in set.
In MacOS-X class clusters do not have designated initialisers, and there is a general rule that -init is treated as the designated initialiser of the class cluster, but that other intitialisers may not work s expected an would need to be individually overridden in any subclass.
GNUstep tries to make it easier to subclass a class cluster, by making class clusters follow the same convention as normal classes, so the designated initialiser is the richest initialiser. This means that all other initialisers call the documented designated initialiser (which calls -init only for MacOS-X compatibility), and anyone writing a subclass only needs to override that one initialiser in order to have all the other ones work.
For MacOS-X compatibility, you may also need to override various other initialisers. Exactly which ones, you will need to determine by trial on a MacOS-X system... and may vary between releases of MacOS-X. So to be safe, on MacOS-X you probably need to re-implement all the class cluster initialisers you might use in conjunction with your subclass.
Initialises a newly allocated set by adding all the objects in the supplied array to the set.
Initialize with (unique elements of) objects in given nil-terminated list.
Initialize to contain (unique elements of)
objects.
Calls
-init
(which does nothing but maintain MacOS-X
compatibility), and needs to be
re-implemented in subclasses in order to
have all other initialisers work.
Initialize with same items as other (items not copied).
Initialises a newly allocated set by adding all the objects in the supplied set.
Return whether set intersection with otherSet is non-empty.
Return whether each set is subset of the other.
Return whether subset of otherSet.
Send each object given message (with no arguments). Identical to -makeObjectsPerformSelector: .
Send each object given message with given argument. Identical to -makeObjectsPerformSelector:withObject: .
Send each object given message (with no arguments). Identical to -makeObjectsPerform: .
Send each object given message with given argument. Identical to -makeObjectsPerform:withObject: .
If anObject is in set, return it (the copy in the set).
Return enumerator over objects in set. Order is undefined.
- Declared in:
- Foundation/NSSet.h
Standards:
- NotOpenStep
- NotMacOS-X
- GNUstep
Utility methods for using a counted set to handle uniquing of objects.
Method summary
This method removes from the set all objects whose count is less than or equal to the specified value.
This is useful where a counted set is used for uniquing objects. The set can be periodically purged of objects that have only been added once - and are therefore simply wasting space.
If the supplied object (or one equal to it as determined by the [NSObject -isEqual:] method) is already present in the set, the count for that object is incremented, the supplied object is released, and the object in the set is retained and returned. Otherwise, the supplied object is added to the set and returned.
This method is useful for uniquing objects - the
init method of a class need simply end with -
return [myUniquingSet unique: self];