net.ontopia.utils
Class SynchronizedCompactHashSet<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.SynchronizedCompactHashSet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public class SynchronizedCompactHashSet<E>
extends CompactHashSet<E>

INTERNAL: Extends CompactHashSet to make it synchronized. Saves memory compared with having to wrap the set in a SynchronizedSet.


Field Summary
 
Fields inherited from class net.ontopia.utils.CompactHashSet
deletedObject, elements, freecells, INITIAL_SIZE, LOAD_FACTOR, modCount, nullObject, objects
 
Constructor Summary
SynchronizedCompactHashSet()
           
SynchronizedCompactHashSet(java.util.Collection c)
           
SynchronizedCompactHashSet(int size)
           
 
Method Summary
 boolean add(java.lang.Object o)
          Adds the specified element to this set if it is not already present.
 boolean addAll(java.util.Collection coll)
           
 void clear()
          Removes all of the elements from this set.
 boolean contains(java.lang.Object o)
          Returns true if this set contains the specified element.
 boolean containsAll(java.util.Collection coll)
           
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 boolean isEmpty()
          Returns true if this set contains no elements.
 java.util.Iterator<E> iterator()
          Returns an iterator over the elements in this set.
 boolean remove(java.lang.Object o)
          Removes the specified element from the set.
 boolean removeAll(java.util.Collection coll)
           
 boolean retainAll(java.util.Collection coll)
           
 int size()
          Returns the number of elements in this set (its cardinality).
 java.lang.Object[] toArray()
           
<E> E[]
toArray(E[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class net.ontopia.utils.CompactHashSet
dump, rehash, rehash
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynchronizedCompactHashSet

public SynchronizedCompactHashSet()

SynchronizedCompactHashSet

public SynchronizedCompactHashSet(java.util.Collection c)

SynchronizedCompactHashSet

public SynchronizedCompactHashSet(int size)
Method Detail

size

public int size()
Description copied from class: CompactHashSet
Returns the number of elements in this set (its cardinality).

Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>
Overrides:
size in class CompactHashSet<E>

isEmpty

public boolean isEmpty()
Description copied from class: CompactHashSet
Returns true if this set contains no elements.

Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.Set<E>
Overrides:
isEmpty in class CompactHashSet<E>

contains

public boolean contains(java.lang.Object o)
Description copied from class: CompactHashSet
Returns true if this set contains the specified element.

Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.Set<E>
Overrides:
contains in class CompactHashSet<E>
Parameters:
o - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>
Overrides:
toArray in class CompactHashSet<E>

toArray

public <E> E[] toArray(E[] a)
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>
Overrides:
toArray in class CompactHashSet<E>

iterator

public java.util.Iterator<E> iterator()
Description copied from class: CompactHashSet
Returns an iterator over the elements in this set. The elements are returned in no particular order.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>
Overrides:
iterator in class CompactHashSet<E>
Returns:
an Iterator over the elements in this set.
See Also:
ConcurrentModificationException

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<E>
Specified by:
add in interface java.util.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(java.lang.Object o)
Description copied from class: CompactHashSet
Removes the specified element from the set.

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

containsAll

public boolean containsAll(java.util.Collection coll)
Specified by:
containsAll in interface java.util.Collection<E>
Specified by:
containsAll in interface java.util.Set<E>
Overrides:
containsAll in class java.util.AbstractCollection<E>

addAll

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

removeAll

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

retainAll

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

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<E>
Specified by:
clear in interface java.util.Set<E>
Overrides:
clear in class CompactHashSet<E>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<E>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<E>
Specified by:
equals in interface java.util.Set<E>
Overrides:
equals in class java.util.AbstractSet<E>

hashCode

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


Copyright © 2000-2012 Ontopia.