|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webobjects.foundation.NSSet
com.webobjects.foundation.NSMutableSet
public class NSMutableSet
NSMutableSet provides support for the mathematical concept of a set which, unlike its parent NSSet, may have members added or removed after its creation.
The following table 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.
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 sets, whether during construction (for all sets) or modification (for mutable sets), add each member to the set directly. This means that you must ensure that the members do not change. If the members are expected to change for any reason, you should make
copies of them and add the copies to the set or otherwise guarentee that the members do not change with respect to either the equals
or hashCode
methods.
Set
,
HashSet
,
NSMutableSet.addObject(java.lang.Object)
,
NSMutableSet.removeObject(java.lang.Object)
,
NSMutableSet.removeAllObjects()
,
NSMutableSet.unionSet(com.webobjects.foundation.NSSet)
,
NSMutableSet.intersectSet(com.webobjects.foundation.NSSet)
,
NSMutableSet.subtractSet(com.webobjects.foundation.NSSet)
,
NSMutableSet.addObjectsFromArray(com.webobjects.foundation.NSArray)
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSCoding |
---|
NSCoding.Support |
Field Summary |
---|
Fields inherited from class com.webobjects.foundation.NSSet |
---|
CheckForNull, EmptySet, IgnoreNull |
Constructor Summary | |
---|---|
NSMutableSet()
Creates an empty NSMutableSet. |
|
NSMutableSet(Collection collection)
Creates an NSMutableSet containing all the elements in collection |
|
NSMutableSet(Object object)
Creates an NSMutableSet containing a single object object . |
|
NSMutableSet(Object[] objects)
Creates an NSMutableSet containing the all the elements in objects . |
|
NSMutableSet(int capacity)
Creates an empty NSMutableSet prepared to hold at least capacity members. |
|
NSMutableSet(NSArray objects)
Creates an NSMutableSet containing the all the elements in objects . |
|
NSMutableSet(NSSet otherSet)
Creates an NSMutableSet containing all the members in otherSet . |
Method Summary | |
---|---|
boolean |
add(Object element)
Operation not supported |
boolean |
addAll(Collection collection)
Operation not supported |
void |
addObject(Object object)
Adds the specified object to this set if it is not already a member. |
void |
addObjectsFromArray(NSArray array)
Adds each object contained in array to this set, if the object is not already a member. |
void |
clear()
Operation not supported |
Object |
clone()
Creates a clone of the receiver. |
NSSet |
immutableClone()
Creates a new NSSet which has the same members as this set. |
void |
intersectSet(NSSet otherSet)
Removes from this set each object that is not a member of otherSet . |
NSMutableSet |
mutableClone()
Creates a new NSMutableSet which has the same members as this set. |
boolean |
remove(Object element)
Operation not supported |
boolean |
removeAll(Collection collection)
Operation not supported |
void |
removeAllObjects()
Empties the set of all its members. |
Object |
removeObject(Object object)
Removes object from the set. |
boolean |
retainAll(Collection collection)
Operation not supported |
void |
setSet(NSSet otherSet)
Makes this set contain exactly the same members as otherSet The current members in this set are discarded. |
void |
subtractSet(NSSet otherSet)
Removes from this set each object contained in otherSet that is also currently a member of this set. |
void |
unionSet(NSSet otherSet)
Adds each object contained in otherSet to this set, if that object is not already a member. |
Methods inherited from class com.webobjects.foundation.NSSet |
---|
allObjects, anyObject, classForCoder, contains, containsAll, containsObject, count, decodeObject, emptySet, encodeWithCoder, equals, hashCode, hashSet, intersectsSet, isEmpty, isEqualToSet, isSubsetOfSet, iterator, member, objectEnumerator, objectsNoCopy, setByIntersectingSet, setBySubtractingSet, setByUnioningSet, size, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NSMutableSet()
For better performance, one should use NSMutableSet(int capacity) instead.
NSMutableSet.NSMutableSet(int capacity)
public NSMutableSet(int capacity)
capacity
members. NSMutableSets grow as necessary, so this is a recommended performance enhancement.
capacity
- a size hint for the expected number of memberspublic NSMutableSet(Object object)
object
.
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.
object
- the single member object contained in the setpublic NSMutableSet(Object[] objects)
objects
.
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.
objects
- an array of initial members for the new setpublic NSMutableSet(NSArray objects)
objects
.
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.
objects
- an array of initial members for the new setpublic NSMutableSet(NSSet otherSet)
otherSet
. One should use mutableClone
instead.
otherSet
- the set to duplicateNSMutableSet.mutableClone()
public NSMutableSet(Collection collection)
collection
collection
- object that implements java.util.Collection
IllegalArgumentException
- if a null
element exists in collection
or the collection parameter is null
.Set
Method Detail |
---|
public void addObject(Object object)
If object
is already present in the set, this method has no effect on either the set or on object
.
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.
object
- the new memberNSMutableSet.addObjectsFromArray(com.webobjects.foundation.NSArray)
,
NSMutableSet.unionSet(com.webobjects.foundation.NSSet)
public Object removeObject(Object object)
object
from the set.
object
- object that is to be removed from the set
null
if object
was not a memberNSMutableSet.removeAllObjects()
,
NSMutableSet.intersectSet(com.webobjects.foundation.NSSet)
,
NSMutableSet.subtractSet(com.webobjects.foundation.NSSet)
public void removeAllObjects()
NSMutableSet.removeObject(java.lang.Object)
,
NSMutableSet.intersectSet(com.webobjects.foundation.NSSet)
,
NSMutableSet.subtractSet(com.webobjects.foundation.NSSet)
public void setSet(NSSet otherSet)
otherSet
The current members in this set are discarded.
otherSet
- the new members for this setpublic void addObjectsFromArray(NSArray array)
array
to this set, if the 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.
array
- objects are contained in thisNSMutableSet.addObject(java.lang.Object)
,
NSMutableSet.unionSet(com.webobjects.foundation.NSSet)
public void intersectSet(NSSet otherSet)
otherSet
.
otherSet
- objects that are not members of otherSet
are removedNSMutableSet.removeObject(java.lang.Object)
,
NSMutableSet.removeAllObjects()
,
NSMutableSet.subtractSet(com.webobjects.foundation.NSSet)
public void subtractSet(NSSet otherSet)
otherSet
that is also currently a member of this set. If any member of otherSet
is not present in this set, this method has no effect on that member.
otherSet
- objects contained in otherSet
are removed if they are also members of this setNSMutableSet.removeObject(java.lang.Object)
,
NSMutableSet.removeAllObjects()
,
NSMutableSet.intersectSet(com.webobjects.foundation.NSSet)
public void unionSet(NSSet otherSet)
otherSet
to this set, if that object is not already a member. If any member of otherSet
is already a member of this set, this method has no effect on that member.
otherSet
- each object contained in otherSet
are added to this setNSMutableSet.addObject(java.lang.Object)
,
NSMutableSet.addObjectsFromArray(com.webobjects.foundation.NSArray)
public Object clone()
clone
in class NSSet
Object.clone()
,
NSMutableSet.immutableClone()
,
NSMutableSet.mutableClone()
public NSSet immutableClone()
immutableClone
in class NSSet
Object.clone()
,
NSMutableSet.mutableClone()
public NSMutableSet mutableClone()
mutableClone
in class NSSet
Object.clone()
,
NSMutableSet.immutableClone()
public boolean remove(Object element)
NSSet
remove
in interface Collection
remove
in interface Set
remove
in class NSSet
element
- to be removed from this list, if present.Collection.remove(java.lang.Object)
public void clear()
NSSet
clear
in interface Collection
clear
in interface Set
clear
in class NSSet
Collection.clear()
,
NSMutableSet.removeAllObjects()
public boolean retainAll(Collection collection)
NSSet
retainAll
in interface Collection
retainAll
in interface Set
retainAll
in class NSSet
Collection.retainAll(java.util.Collection)
public boolean removeAll(Collection collection)
NSSet
removeAll
in interface Collection
removeAll
in interface Set
removeAll
in class NSSet
Collection.removeAll(java.util.Collection)
public boolean add(Object element)
NSSet
add
in interface Collection
add
in interface Set
add
in class NSSet
element
- -
object to addCollection.add(E)
public boolean addAll(Collection collection)
NSSet
addAll
in interface Collection
addAll
in interface Set
addAll
in class NSSet
collection
- -
collection to addCollection.addAll(java.util.Collection)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |