Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

NSMutableSet


Inherits from:
NSSet : Object
Implements:
Cloneable
java.io.Serializable
NSCoding
Package:
com.webobjects.foundation


Class Description


The NSMutableSet class declares the programmatic interface to an object that manages a mutable set of objects. NSMutableSet provides support for the mathematical concept of a set. A set, both in its mathematical sense, and in the NSMutableSet implementation, is an unordered collection of distinct elements. The NSSet class supports creating and managing immutable sets.

Table 0-11 describes the NSMutableSet methods that provide the basis for all NSMutableSet's other methods; that is, all other methods are implemented in terms of these five. If you create a subclass of NSMutableSet, you need only ensure that these base methods work properly. Having done so, you can be sure that all your subclass's inherited methods operate properly.


Table 0-11 NSMutableSet's Base API
Method Description
count Returns the number of members in the set.
member Returns the object in the set that is equal to the specified object.
objectsNoCopy Returns the actual array of objects in the set.
removeAllObjects Empties the set of all its members.
removeObject Removes the specified object from the set.

Objects are removed from an NSMutableSet using any of the methods intersectSet, removeAllObjects, removeObject, or subtractSet.

Objects are added to an NSMutableSet with addObject, which adds a single object to the set; addObjectsFromArray, which adds all objects from a specified array to the set; or with unionSet, which adds all the objects from another set.

Methods that add entries to NSMutableSets-whether during construction or modification-add each member to the set directly. This means that you must ensure that the members do not change. If you expect your members to change for any reason, you should make copies of them and add the copies to the set.




Interfaces Implemented


Cloneable
clone
java.io.Serializable
NSCoding
classForCoder
decodeObject
encodeWithCoder


Method Types


Constructors
NSMutableSet
Adding and removing entries
addObject
addObjectsFromArray
removeAllObjects
removeObject
Combining and recombining sets
intersectSet
setSet
subtractSet
unionSet
Copying the set
immutableClone


Constructors



NSMutableSet

public NSMutableSet()

Creates an empty NSMutableSet.

public NSMutableSet(NSArray anArray)

Creates an NSMutableSet containing the objects in anArray.
Note: NSMutableSet assumes that member objects are immutable. If your member objects are mutable, you should make copies of them and add the copies to the set.

public NSMutableSet(NSSet aSet)

Creates an NSMutableSet containing the objects in aSet.

public NSMutableSet(Object anObject)

Creates an NSMutableSet containing a single object anObject.
Note: NSMutableSet assumes that member objects are immutable. If your member objects are mutable, you should make copies of them and add the copies to the set.

public NSMutableSet(Object[] objects[])

Creates an NSMutableSet containing the objects in the objects language array.
Note: NSMutableSet assumes that member objects are immutable. If your member objects are mutable, you should make copies of them and add the copies to the set.

public NSMutableSet(int capacity)

Creates an NSMutableSet that can hold at least capacity objects.


Instance Methods



addObject

public void addObject(Object anObject)

Adds the specified object to the receiver if it is not already a member. If anObject is already present in the set, this method has no effect on either the set or on anObject.
Note: NSMutableSet assumes that member objects are immutable. If your member objects are mutable, you should make copies of them and add the copies to the set.

See Also: addObjectsFromArray, unionSet



addObjectsFromArray

public void addObjectsFromArray(NSArray anArray)

Adds each object contained in anArray to the receiver, if that object is not already a member. If a given element of the array is already present in the set, this method has no effect on either the set or on the array element.
Note: NSMutableSet assumes that member objects are immutable. If your member objects are mutable, you should make copies of them and add the copies to the set.

See Also: addObject, unionSet



clone

public Object clone()

Creates a clone of the receiver. NSMutableSet's implementation simply creates a new NSMutableSet with the objects in the receiver.

immutableClone

public NSSet immutableClone()

Creates an immutable copy (a NSSet) of the receiver.

intersectSet

public void intersectSet(NSSet otherSet)

Removes from the receiver each object that isn't a member of otherSet.

See Also: removeObject, removeAllObjects, subtractSet



mutableClone

public NSMutableArray mutableClone()

Description forthcoming.

removeAllObjects

public void removeAllObjects()

Empties the set of all its members.

See Also: removeObject, intersectSet, subtractSet



removeObject

public void removeObject(Object anObject)

Removes anObject from the set.

See Also: removeAllObjects, intersectSet, subtractSet



setSet

public void setSet(NSSet otherSet)

Empties the receiver, then adds each object contained in otherSet to the receiver.

subtractSet

public void subtractSet(NSSet otherSet)

Removes from the receiver each object contained in otherSet that is also present in the receiver. If any member of otherSet isn't present in the receiving set, this method has no effect on either the receiver or on the otherSet member.

See Also: removeObject, removeAllObjects, intersectSet



unionSet

public void unionSet(NSSet otherSet)

Adds each object contained in otherSet to the receiver, if that object is not already a member. If any member of otherSet is already present in the receiver, this method has no effect on either the receiver or on the otherSet member.

See Also: addObject, addObjectsFromArray



© 2001 Apple Computer, Inc. (Last Published April 17, 2001)


Table of Contents