Project Wonder 5.0

com.webobjects.foundation
Class NSSet<E>

java.lang.Object
  extended by com.webobjects.foundation.NSSet<E>
Type Parameters:
E - type of set contents
All Implemented Interfaces:
_NSFoundationCollection, NSCoding, Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
NSMutableSet

public class NSSet<E>
extends Object
implements Cloneable, Serializable, NSCoding, _NSFoundationCollection, Set<E>

NSSet reimplementation to support JDK 1.5 templates. Use with

 NSSet<E> setA = new NSSet<E>(NSArray<E> listA);
 NSSet<E> setB = new NSSet<E>(NSArray<E> listB);
 logger.debug("intersection contains " + setA.setByIntersectingSet(setB));
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSCoding
NSCoding._BigDecimalSupport, NSCoding._BigIntegerSupport, NSCoding._BooleanSupport, NSCoding._ByteSupport, NSCoding._CharacterSupport, NSCoding._DateSupport, NSCoding._DoubleSupport, NSCoding._FloatSupport, NSCoding._IntegerSupport, NSCoding._LongSupport, NSCoding._NumberSupport, NSCoding._ShortSupport, NSCoding._StringSupport, NSCoding.Support
 
Field Summary
protected  int _capacity
           
static Class _CLASS
           
protected  int _count
           
protected  int _deletionLimit
           
protected  byte[] _flags
           
protected  int _hashCache
           
protected  int _hashtableBuckets
           
protected static int _NSSetClassHashCode
           
protected  Object[] _objects
           
protected  Object[] _objectsCache
           
static NSSet EmptySet
           
 
Constructor Summary
NSSet()
           
NSSet(Collection<? extends E> collection)
           
NSSet(E object)
           
NSSet(E[] objects)
           
NSSet(E object, E... objects)
           
NSSet(NSArray<? extends E> objects)
           
NSSet(NSSet<? extends E> otherSet)
           
NSSet(Set<? extends E> set, boolean ignoreNull)
           
 
Method Summary
 Object[] _allObjects()
           
protected  void _clearDeletionsAndCollisions()
           
protected  void _ensureCapacity(int capacity)
           
protected  void _initializeSet()
           
protected  void _setCapacity(int capacity)
           
protected  void _setCount(int count)
           
 int _shallowHashCode()
           
 boolean add(E o)
           
 boolean addAll(Collection<? extends E> c)
           
 NSArray<E> allObjects()
           
 E anyObject()
           
protected  int capacity()
           
 Class classForCoder()
           
 void clear()
           
 Object clone()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean containsObject(Object object)
           
 int count()
           
static Object decodeObject(NSCoder coder)
           
static
<T> NSSet<T>
emptySet()
           
 void encodeWithCoder(NSCoder coder)
           
 boolean equals(Object object)
           
 int hashCode()
           
 HashSet<E> hashSet()
           
 NSSet<E> immutableClone()
           
 boolean intersectsSet(NSSet<?> otherSet)
           
 boolean isEmpty()
           
 boolean isEqualToSet(NSSet<?> otherSet)
           
 boolean isSubsetOfSet(NSSet<?> otherSet)
           
 Iterator<E> iterator()
           
 E member(Object object)
           
 NSMutableSet<E> mutableClone()
           
 Enumeration<E> objectEnumerator()
           
protected  Object[] objectsNoCopy()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 NSSet<E> setByIntersectingSet(NSSet<?> otherSet)
           
 NSSet<E> setBySubtractingSet(NSSet<?> otherSet)
           
 NSSet<E> setByUnioningSet(NSSet<? extends E> otherSet)
           
 int size()
           
 Object[] toArray()
           
<T> T[]
toArray(T[] objects)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_CLASS

public static final Class _CLASS

_NSSetClassHashCode

protected static int _NSSetClassHashCode

EmptySet

public static final NSSet EmptySet

_capacity

protected transient int _capacity

_count

protected transient int _count

_deletionLimit

protected transient int _deletionLimit

_flags

protected transient byte[] _flags

_hashCache

protected transient int _hashCache

_hashtableBuckets

protected transient int _hashtableBuckets

_objects

protected Object[] _objects

_objectsCache

protected transient Object[] _objectsCache
Constructor Detail

NSSet

public NSSet()

NSSet

public NSSet(Collection<? extends E> collection)

NSSet

public NSSet(NSArray<? extends E> objects)

NSSet

public NSSet(NSSet<? extends E> otherSet)

NSSet

public NSSet(Set<? extends E> set,
             boolean ignoreNull)

NSSet

public NSSet(E object)

NSSet

public NSSet(E[] objects)

NSSet

public NSSet(E object,
             E... objects)
Method Detail

decodeObject

public static Object decodeObject(NSCoder coder)

_allObjects

public Object[] _allObjects()

_clearDeletionsAndCollisions

protected void _clearDeletionsAndCollisions()

_ensureCapacity

protected void _ensureCapacity(int capacity)

_initializeSet

protected void _initializeSet()

_shallowHashCode

public int _shallowHashCode()
Specified by:
_shallowHashCode in interface _NSFoundationCollection

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>

allObjects

public NSArray<E> allObjects()

anyObject

public E anyObject()

classForCoder

public Class classForCoder()
Specified by:
classForCoder in interface NSCoding

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>

clone

public Object clone()
Overrides:
clone in class Object

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface Set<E>

containsObject

public boolean containsObject(Object object)

count

public int count()

_setCount

protected void _setCount(int count)

capacity

protected int capacity()

_setCapacity

protected void _setCapacity(int capacity)

encodeWithCoder

public void encodeWithCoder(NSCoder coder)
Specified by:
encodeWithCoder in interface NSCoding

emptySet

public static <T> NSSet<T> emptySet()

equals

public boolean equals(Object object)
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface Set<E>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface Set<E>
Overrides:
hashCode in class Object

hashSet

public HashSet<E> hashSet()

immutableClone

public NSSet<E> immutableClone()

intersectsSet

public boolean intersectsSet(NSSet<?> otherSet)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>

isEqualToSet

public boolean isEqualToSet(NSSet<?> otherSet)

isSubsetOfSet

public boolean isSubsetOfSet(NSSet<?> otherSet)

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>

member

public E member(Object object)

mutableClone

public NSMutableSet<E> mutableClone()

objectEnumerator

public Enumeration<E> objectEnumerator()

objectsNoCopy

protected Object[] objectsNoCopy()

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<E>

setByIntersectingSet

public NSSet<E> setByIntersectingSet(NSSet<?> otherSet)

setBySubtractingSet

public NSSet<E> setBySubtractingSet(NSSet<?> otherSet)

setByUnioningSet

public NSSet<E> setByUnioningSet(NSSet<? extends E> otherSet)

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>

toArray

public <T> T[] toArray(T[] objects)
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>

toString

public String toString()
Overrides:
toString in class Object

Last updated: Wed, Feb 22, 2012 • 07:00 AM EST

Copyright © 2002 – 2011 Project Wonder.