org.norther.tammi.acorn.util
Class ConcurrentReadSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.norther.tammi.acorn.util.ConcurrentReadSet
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Set

public class ConcurrentReadSet
extends AbstractSet
implements Cloneable, Serializable

An implementation of the Set interface backed by a ConcurrentReadMap instance.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ConcurrentReadSet()
          Constructs a new set.
ConcurrentReadSet(Collection c)
          Constructs a new set containing the elements in the specified collection.
ConcurrentReadSet(int capacity)
          Constructs a new set with the specified capacity.
ConcurrentReadSet(int capacity, float loadFactor)
          Constructs a new set with the specified capacity and load factor.
 
Method Summary
 boolean add(Object value)
          Adds the specified element to this set if not already present.
 void clear()
          Removes all of the elements from this set.
 Object clone()
          Returns a shallow copy of this set.
 boolean contains(Object o)
          Checks whether this set contains the specified element.
 boolean isEmpty()
          Checks whether this set contains any elements.
 Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(Object value)
          Removes the specified element from this set if present.
 int size()
          Returns the number of elements in this set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray, toArray
 

Constructor Detail

ConcurrentReadSet

public ConcurrentReadSet()
Constructs a new set.


ConcurrentReadSet

public ConcurrentReadSet(Collection c)
Constructs a new set containing the elements in the specified collection.

Parameters:
c - an initial collection.

ConcurrentReadSet

public ConcurrentReadSet(int capacity)
Constructs a new set with the specified capacity.

Parameters:
capacity - the initial capacity.

ConcurrentReadSet

public ConcurrentReadSet(int capacity,
                         float loadFactor)
Constructs a new set with the specified capacity and load factor.

Parameters:
capacity - the initial capacity.
loadFactor - the load factor.
Method Detail

clone

public Object clone()
Returns a shallow copy of this set. The elements in the set are not cloned.

Overrides:
clone in class Object
Returns:
a shallow copy of this set.

add

public boolean add(Object value)
Adds the specified element to this set if not already present.

Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection
Parameters:
value - the element to be added.
Returns:
true if added, false otherwise.

remove

public boolean remove(Object value)
Removes the specified element from this set if present.

Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection
Parameters:
value - the element to be removed.
Returns:
true if removed, false otherwise.

clear

public void clear()
Removes all of the elements from this set.

Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection

contains

public boolean contains(Object o)
Checks whether this set contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection
Parameters:
o - the element to check.
Returns:
true if found, false otherwise.

isEmpty

public boolean isEmpty()
Checks whether this set contains any elements.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
Overrides:
isEmpty in class AbstractCollection
Returns:
true if empty, false otherwise.

size

public int size()
Returns the number of elements in this set.

Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection
Returns:
the number of elements.

iterator

public Iterator iterator()
Returns an iterator over the elements in this set. The elements are not in any particular order.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection
Returns:
an iterator.


Copyright © 2004 The Norther Organization. All rights reserved.