net.ontopia.utils
Class UniqueSet<E>

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

public class UniqueSet<E>
extends CompactHashSet<E>

INTERNAL:


Field Summary
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
UniqueSet()
           
UniqueSet(Collection<E> c)
           
UniqueSet(int size)
           
UniqueSet(UniqueSet<E> s)
           
UniqueSet(UniqueSet<E> s1, UniqueSet<E> s2)
           
 
Method Summary
 boolean add(Object o)
          Adds the specified element to this set if it is not already present.
 UniqueSet<E> add(UniqueSet<E> set, Object o, boolean dereference)
           
 boolean addAll(Collection<? extends E> coll)
           
 void clear()
          Removes all of the elements from this set.
 void dereference(UniqueSet<E> set)
           
 void dump()
          INTERNAL: Used for debugging only.
protected  boolean equalsAdd(UniqueSet<E> other, Object o)
           
protected  boolean equalsRemove(UniqueSet<E> other, Object o)
           
 UniqueSet<E> get(Set<E> set)
          INTERNAL: Get the internal representation of a given set.
 int getReferenceCount()
           
 int hashCode()
           
protected  E lookup(Object o)
          INTERNAL: Looks up the object in the hashset and returns the actual object stored at the hashset.
 boolean remove(Object o)
          Removes the specified element from the set.
 UniqueSet<E> remove(UniqueSet<E> set, Object o, boolean dereference)
           
 boolean removeAll(Collection<?> coll)
           
 boolean retainAll(Collection<?> coll)
           
 String toString()
           
 
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll
 

Field Detail

hc

protected int hc

hc_modCount

protected int hc_modCount
Constructor Detail

UniqueSet

public UniqueSet()

UniqueSet

public UniqueSet(int size)

UniqueSet

public UniqueSet(Collection<E> c)

UniqueSet

public UniqueSet(UniqueSet<E> s)

UniqueSet

public UniqueSet(UniqueSet<E> s1,
                 UniqueSet<E> s2)
Method Detail

getReferenceCount

public int getReferenceCount()

get

public UniqueSet<E> get(Set<E> set)
INTERNAL: Get the internal representation of a given set. The initial reference count is 1.


lookup

protected E lookup(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.


dereference

public void dereference(UniqueSet<E> set)

equalsAdd

protected boolean equalsAdd(UniqueSet<E> other,
                            Object o)

equalsRemove

protected boolean equalsRemove(UniqueSet<E> other,
                               Object o)

add

public UniqueSet<E> add(UniqueSet<E> set,
                        Object o,
                        boolean dereference)

remove

public UniqueSet<E> remove(UniqueSet<E> set,
                           Object o,
                           boolean dereference)

dump

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

Overrides:
dump in class CompactHashSet<E>

add

public boolean add(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 Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class CompactHashSet<E>
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(Object o)
Description copied from class: CompactHashSet
Removes the specified element from the set.

Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class CompactHashSet<E>

addAll

public boolean addAll(Collection<? extends E> coll)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class AbstractCollection<E>

removeAll

public boolean removeAll(Collection<?> coll)
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>
Overrides:
removeAll in class AbstractSet<E>

retainAll

public boolean retainAll(Collection<?> coll)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<E>
Overrides:
retainAll in class AbstractCollection<E>

clear

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

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class CompactHashSet<E>

toString

public String toString()
Overrides:
toString in class AbstractCollection<E>

hashCode

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


Copyright © 2000-2012 Ontopia.