net.ontopia.utils
Class SetPool

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by net.ontopia.utils.CompactHashSet
              extended by net.ontopia.utils.SetPool
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.Set, PoolableSetFactoryIF, SetPoolIF

public class SetPool
extends CompactHashSet
implements SetPoolIF, PoolableSetFactoryIF

INTERNAL: The default SetPool implementation.

Since:
2.0

Field Summary
protected  PoolableSetFactoryIF factory
           
protected  int hc
           
protected  int hc_modCount
           
 
Fields inherited from class net.ontopia.utils.CompactHashSet
deletedObject, elements, freecells, INITIAL_SIZE, LOAD_FACTOR, modCount, nullObject, objects
 
Constructor Summary
SetPool()
           
SetPool(java.util.Collection c)
           
SetPool(java.util.Collection c, PoolableSetFactoryIF factory)
           
SetPool(int size)
           
SetPool(int size, PoolableSetFactoryIF factory)
           
SetPool(PoolableSetFactoryIF factory)
           
 
Method Summary
 boolean add(java.lang.Object o)
          Adds the specified element to this set if it is not already present.
 java.util.Set add(java.util.Set set, java.lang.Object o, boolean dereference)
          INTERNAL: Return a set that is the result of adding the given object from the given set.
 boolean addAll(java.util.Collection coll)
           
 void clear()
          Removes all of the elements from this set.
 PoolableSetIF createSet()
          INTERNAL: Returns a new empty poolable set.
 PoolableSetIF createSet(java.util.Set set)
          INTERNAL: Returns a new poolable set that contains the given elements.
 PoolableSetIF createSetAdd(java.util.Set set, java.lang.Object o)
          INTERNAL: Returns a new poolable set that contains the given elements plus the single object.
 PoolableSetIF createSetRemove(java.util.Set set, java.lang.Object o)
          INTERNAL: Returns a new poolable set that contains the given elements minus the single object.
 void dereference(java.util.Set set)
          INTERNAL: Decrement reference count for the given set.
 void dump()
          INTERNAL: Used for debugging only.
 int hashCode()
           
protected  java.lang.Object lookup(java.lang.Object o)
          INTERNAL: Looks up the object in the hashset and returns the actual object stored at the hashset.
 java.util.Set reference(java.util.Set set)
          INTERNAL: Get the internal representation of a given set.
protected  void registerSet(java.util.Set set)
           
 boolean remove(java.lang.Object o)
          Removes the specified element from the set.
 java.util.Set remove(java.util.Set set, java.lang.Object o, boolean dereference)
          INTERNAL: Return a set that is the result of removing the given object from the given set.
 boolean removeAll(java.util.Collection coll)
           
 boolean retainAll(java.util.Collection coll)
           
protected  void unregisterSet(java.util.Set set)
           
 
Methods inherited from class net.ontopia.utils.CompactHashSet
contains, isEmpty, iterator, rehash, rehash, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSet
equals
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
contains, containsAll, equals, isEmpty, iterator, size, toArray, toArray
 

Field Detail

factory

protected PoolableSetFactoryIF factory

hc

protected int hc

hc_modCount

protected int hc_modCount
Constructor Detail

SetPool

public SetPool()

SetPool

public SetPool(PoolableSetFactoryIF factory)

SetPool

public SetPool(int size)

SetPool

public SetPool(int size,
               PoolableSetFactoryIF factory)

SetPool

public SetPool(java.util.Collection c)

SetPool

public SetPool(java.util.Collection c,
               PoolableSetFactoryIF factory)
Method Detail

createSet

public PoolableSetIF createSet()
Description copied from interface: PoolableSetFactoryIF
INTERNAL: Returns a new empty poolable set.

Specified by:
createSet in interface PoolableSetFactoryIF

createSet

public PoolableSetIF createSet(java.util.Set set)
Description copied from interface: PoolableSetFactoryIF
INTERNAL: Returns a new poolable set that contains the given elements.

Specified by:
createSet in interface PoolableSetFactoryIF

createSetAdd

public PoolableSetIF createSetAdd(java.util.Set set,
                                  java.lang.Object o)
Description copied from interface: PoolableSetFactoryIF
INTERNAL: Returns a new poolable set that contains the given elements plus the single object.

Specified by:
createSetAdd in interface PoolableSetFactoryIF

createSetRemove

public PoolableSetIF createSetRemove(java.util.Set set,
                                     java.lang.Object o)
Description copied from interface: PoolableSetFactoryIF
INTERNAL: Returns a new poolable set that contains the given elements minus the single object.

Specified by:
createSetRemove in interface PoolableSetFactoryIF

registerSet

protected void registerSet(java.util.Set set)

unregisterSet

protected void unregisterSet(java.util.Set set)

reference

public java.util.Set reference(java.util.Set set)
INTERNAL: Get the internal representation of a given set. The initial reference count is 1.

Specified by:
reference in interface SetPoolIF

dereference

public void dereference(java.util.Set set)
Description copied from interface: SetPoolIF
INTERNAL: Decrement reference count for the given set.

Specified by:
dereference in interface SetPoolIF

lookup

protected java.lang.Object lookup(java.lang.Object o)
INTERNAL: Looks up the object in the hashset and returns the actual object stored at the hashset. Note that this might be another object, but one that is considered to be equal. Returns null if the object was not found.


add

public java.util.Set add(java.util.Set set,
                         java.lang.Object o,
                         boolean dereference)
Description copied from interface: SetPoolIF
INTERNAL: Return a set that is the result of adding the given object from the given set. If the dereference flag is set the set reference count of the old set will be decremented by one.

Specified by:
add in interface SetPoolIF

remove

public java.util.Set remove(java.util.Set set,
                            java.lang.Object o,
                            boolean dereference)
Description copied from interface: SetPoolIF
INTERNAL: Return a set that is the result of removing the given object from the given set. If the dereference flag is set the set reference count of the old set will be decremented by one.

Specified by:
remove in interface SetPoolIF

dump

public void dump()
Description copied from class: CompactHashSet
INTERNAL: Used for debugging only.

Overrides:
dump in class CompactHashSet

add

public boolean add(java.lang.Object o)
Description copied from class: CompactHashSet
Adds the specified element to this set if it is not already present.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class CompactHashSet
Parameters:
o - element to be added to this set.
Returns:
true if the set did not already contain the specified element.

remove

public boolean remove(java.lang.Object o)
Description copied from class: CompactHashSet
Removes the specified element from the set.

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Overrides:
remove in class CompactHashSet

addAll

public boolean addAll(java.util.Collection coll)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set
Overrides:
addAll in class java.util.AbstractCollection

removeAll

public boolean removeAll(java.util.Collection coll)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set
Overrides:
removeAll in class java.util.AbstractSet

retainAll

public boolean retainAll(java.util.Collection coll)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set
Overrides:
retainAll in class java.util.AbstractCollection

clear

public void clear()
Description copied from class: CompactHashSet
Removes all of the elements from this set.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set
Overrides:
clear in class CompactHashSet

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.Set
Overrides:
hashCode in class java.util.AbstractSet


Copyright © 2000-2012 Ontopia.