| 
 | WebObjects 5.2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.webobjects.foundation.NSSet
NSSet declares an API for an object that manages a collection of objects similar to a mathematical set. A set, both in its mathematical sense and in the implementation of NSSet, is an unordered collection of distinct elements. The NSMutableSet subclass is provided for sets whose contents may be altered.
Use sets as an alternative to arrays when the order of elements is not important and performance in testing whether an object is contained in the set is a consideration. While arrays are ordered, testing for membership is much slower than with sets.
 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
 guarantee that the members do not change with respect to either the equals or
 hashCode methods.
 
The following table describes the NSSet methods that provide the basis for all NSSet's other methods; that is, all other methods are implemented in terms of these three. If you create a subclass of NSSet, you need only ensure that these base methods work properly. Having done so, you can be sure that all his 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 | 
 NSSet provides methods for querying the elements of the set. The
 allObjects method returns an array containing the objects in a set.
 The anyObject method returns some object in the set. Additionally,
 intersectsSet tests for set intersection, isEqualToSet tests for set
 equality, and isSubsetOfSet tests for one set being a subset of another.
 
 The objectEnumerator method provides for traversing elements of
 the set one by one.
Set, 
HashSet, 
count(), 
allObjects(), 
member(java.lang.Object), 
intersectsSet(com.webobjects.foundation.NSSet), Serialized Form| Inner classes inherited from class com.webobjects.foundation.NSCoding | 
| NSCoding.Support | 
| Field Summary | |
| static NSSet | EmptySetA shared NSSet instance containing no members. | 
| Constructor Summary | |
| NSSet()Creates an empty NSSet. | |
| NSSet(NSArray objects)Creates an NSSet containing all the elements in objectsNote: NSSet assumes that the member objects are immutable. | |
| NSSet(NSSet otherSet)Creates a new NSSet containing the same objects as another NSSet. | |
| NSSet(Object object)Creates an NSSet containing the single object. | |
| NSSet(Object[] objects)Creates an NSSet containing all the elements in objectsNote: NSSet assumes that the member objects are immutable. | |
| Method Summary | |
|  NSArray | allObjects()Provides an array with all the members of this NSSet. | 
|  Object | anyObject()Returns one of the objects in this set, essentially chosen at random, or nullif the set contains no objects. | 
|  Class | classForCoder()Conformance with NSCoding. | 
|  Object | clone()Since NSSets are immutable, there's no need to make an actual copy. | 
|  boolean | containsObject(Object object)Indicates whether a objectis a member of this NSSet as
 determined byequals | 
|  int | count() | 
| static Object | decodeObject(NSCoder coder)Creates an NSSet from the data in an NSCoder. | 
|  void | encodeWithCoder(NSCoder coder)Encodes the receiver using coder. | 
|  boolean | equals(Object object)Determines whether this NSSet is equal to objectThis istrueifobjectis an NSSet or subclass
 of NSSet and both sets contain identical members. | 
|  int | hashCode()Provides an appropriate hash code useful for storing this NSSet in a hash-based data structure. | 
|  NSSet | immutableClone()Since the NSSets are immutable, there's no need to make an actual | 
|  boolean | intersectsSet(NSSet otherSet)The result of this method corresponds to the mathematical concept of disjoint sets: if the sets are not disjoint, this method returns true; otherwise, it returnsfalse. | 
|  boolean | isEqualToSet(NSSet otherSet)Provided for backward compatibility. | 
|  boolean | isSubsetOfSet(NSSet otherSet)Determines whether every member of this NSSet is a member of otherSet. | 
|  Object | member(Object object)Determines whether an object is a member of this NSSet based on the results of the object's equalsmethod. | 
|  NSMutableSet | mutableClone()This method creates a duplicate NSMutableSet with the same objects. | 
|  Enumeration | objectEnumerator()Provides an Enumeration object that can be used to access each member of this NSSet. | 
| protected  Object[] | objectsNoCopy()This method should be used only by subclasses. | 
|  NSSet | setByIntersectingSet(NSSet otherSet)Creates a new NSSet that is the result of intersecting another NSSet with this NSSet. | 
|  NSSet | setBySubtractingSet(NSSet otherSet)Creates a new NSSet whose members are in this NSSet but not in otherSet. | 
|  NSSet | setByUnioningSet(NSSet otherSet)Creates a new NSSet whose members are in this NSSet or in otherSet, or both. | 
|  String | toString()The string has the form "(object1, object2, ...)". | 
| Methods inherited from class java.lang.Object | 
| finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
public static final NSSet EmptySet
| Constructor Detail | 
public NSSet()
EmptySet constant.EmptySetpublic NSSet(Object object)
object - single object contained in the new NSSetpublic NSSet(Object[] objects)
objects
 Note: NSSet assumes that the member objects are immutable.
 If your member objects are mutable, you should make copies of them
 and add the copies to the set.objects - array of objects to be contained in the new NSSetpublic NSSet(NSArray objects)
objects
 Note: NSSet assumes that the member objects are immutable.
 If your member objects are mutable, you should make copies of them
 and add the copies to the set.objects - array of objects to be contained in the new NSSetpublic NSSet(NSSet otherSet)
immutableClone instead.
 Note: NSSet assumes that the member objects are immutable.
 If your member objects are mutable, you should make copies of them
 and add the copies to the set.otherSet - the set to duplicateimmutableClone(), 
mutableClone(), 
clone()| Method Detail | 
public NSArray allObjects()
anyObject(), 
objectEnumerator()public Object anyObject()
null if the set contains no objects.null if this NSSet is emptyallObjects(), 
objectEnumerator()public Class classForCoder()
classForCoder in interface NSCodingNSCodingpublic Object clone()
clone in class ObjectthisObject.clone(), 
immutableClone(), 
mutableClone()public boolean containsObject(Object object)
object is a member of this NSSet as
 determined by equalsobject - object to search for in this NSSettrue if object is a member of this NSSetmember(java.lang.Object)public int count()
public static Object decodeObject(NSCoder coder)
coder - NSCoder from which the new NSSet's members are derived fromNSCodingpublic void encodeWithCoder(NSCoder coder)
NSCodingcoder. Object type information along with an
 object's data is stored.encodeWithCoder in interface NSCodingcom.webobjects.foundation.NSCodingcoder - an NSCoder object that will be used to encode object of classes that
              implement this interfaceNSCoderpublic boolean equals(Object object)
object
 This is true if object is an NSSet or subclass
 of NSSet and both sets contain identical members.
 Two sets have equal contents if they each have
 the same number of members and if each member matches a member in the
 other set as determined by equals.equals in class Objectobject - the object this NSSet is compared againsttrue if object is an NSSet equal to this NSSetObject.equals(java.lang.Object), 
intersectsSet(com.webobjects.foundation.NSSet), 
isSubsetOfSet(com.webobjects.foundation.NSSet)public int hashCode()
hashCode in class ObjectObject.hashCode()public NSSet immutableClone()
mutableClone(), 
Object.clone()public boolean intersectsSet(NSSet otherSet)
true; otherwise, it returns false.otherSet - NSSet this NSSet is compared againsttrue if at least one object in this NSSet is also
                 a member of otherSetisSubsetOfSet(com.webobjects.foundation.NSSet)public boolean isEqualToSet(NSSet otherSet)
equals instead.otherSet - NSSet this NSSet is compared againsttrue if the contents of otherSet are equal to the
                 contents of this NSSetequals(java.lang.Object)public boolean isSubsetOfSet(NSSet otherSet)
otherSet.otherSet - the potential supersettrue if this NSSet is a subset of otherSetintersectsSet(com.webobjects.foundation.NSSet)public Object member(Object object)
equals method.object - object to search for in this NSSetobject from this NSSet, or null if object is not a member.Object.equals(java.lang.Object)public NSMutableSet mutableClone()
immutableClone(), 
Object.clone()public Enumeration objectEnumerator()
allObjects method to create a snapshot
 of this set's members. Enumerate over the snapshot, but make your
 modifications to the original set.allObjects(), 
Enumerationprotected Object[] objectsNoCopy()
public NSSet setByIntersectingSet(NSSet otherSet)
otherSet.otherSet - NSSet to intersect this NSSet withotherSet have in commonintersectsSet(com.webobjects.foundation.NSSet), 
isSubsetOfSet(com.webobjects.foundation.NSSet), 
setBySubtractingSet(com.webobjects.foundation.NSSet), 
setByUnioningSet(com.webobjects.foundation.NSSet)public NSSet setBySubtractingSet(NSSet otherSet)
otherSet.otherSet - NSSet whose members are subtracted from this NSSetotherSetintersectsSet(com.webobjects.foundation.NSSet), 
isSubsetOfSet(com.webobjects.foundation.NSSet), 
setByIntersectingSet(com.webobjects.foundation.NSSet), 
setByUnioningSet(com.webobjects.foundation.NSSet)public NSSet setByUnioningSet(NSSet otherSet)
otherSet, or both.otherSet - NSSet whose members are added to this NSSetotherSetintersectsSet(com.webobjects.foundation.NSSet), 
isSubsetOfSet(com.webobjects.foundation.NSSet), 
setByIntersectingSet(com.webobjects.foundation.NSSet), 
setBySubtractingSet(com.webobjects.foundation.NSSet)public String toString()
toString in class Object| 
 | Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||