|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet
org.norther.tammi.acorn.util.ArrayAsSet
public class ArrayAsSet
An implementation of the Set interface avoiding
synchronization by making a new copy of its back-end array whenever it is
structurally modified. The solution consumes memory and is not suitable for
frequently changing sets, but provides a non-blocking container for reader
oriented tasks.
Note that iterators do not support modifications.
Based on Doug Lea's CopyOnWriteArraySet .
| Constructor Summary | |
|---|---|
ArrayAsSet()
Constructs an empty set. |
|
ArrayAsSet(ArrayAsList l)
Constructs a set with the back-end list. |
|
ArrayAsSet(Collection c)
Constructs a set containing the elements of the specified collection. |
|
ArrayAsSet(Object[] array)
Constructs a set using the specified array as its back-end and maintaining the component type of the array during modifications. |
|
ArrayAsSet(Object[] array,
boolean force)
Constructs a set using the specified array as its back-end without optionally removing duplicate elements and maintaining the component type of the array during modifications. |
|
| Method Summary | |
|---|---|
boolean |
add(int index,
Object o)
Adds an object to the set at the specified position. |
boolean |
add(Object o)
|
boolean |
addAll(Collection c)
|
void |
clear()
|
Object |
clone()
Returns a shallow copy of this set instance. |
boolean |
contains(Object o)
|
boolean |
containsAll(Collection c)
|
int |
copyAll(int index,
Object[] source)
Copies missing elements from the specified array to the given position of the back-end. |
int |
copyAll(Object[] source)
Copies missing elements from the specified array to the back-end. |
Object[] |
getArray()
Gets a snapshot of the back-end array. |
boolean |
isEmpty()
|
Iterator |
iterator()
|
Object |
remove(int index)
Removes an object from the set at the specified position. |
boolean |
remove(Object o)
|
boolean |
removeAll(Collection c)
|
boolean |
retainAll(Collection c)
|
int |
size()
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] a)
|
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode |
| Methods inherited from class java.util.AbstractCollection |
|---|
toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayAsSet()
public ArrayAsSet(ArrayAsList l)
l - the back-end list.public ArrayAsSet(Collection c)
c - the collection whose elements are to be copied.public ArrayAsSet(Object[] array)
array - the array, which is used as the back-end.
public ArrayAsSet(Object[] array,
boolean force)
array - the array, which is used as the back-end.force - if true, duplicates, if any, are not removed.| Method Detail |
|---|
public Object clone()
clone in class Objectpublic int copyAll(Object[] source)
source - the array to copy.
public int copyAll(int index,
Object[] source)
index - the index of the elements.source - the array to copy.
IndexOutOfBoundsException - for invalid index.public int size()
size in interface Collectionsize in interface Setsize in class AbstractCollectionpublic boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface SetisEmpty in class AbstractCollectionpublic boolean contains(Object o)
contains in interface Collectioncontains in interface Setcontains in class AbstractCollectionpublic Object[] toArray()
toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionpublic Object[] toArray(Object[] a)
toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionpublic void clear()
clear in interface Collectionclear in interface Setclear in class AbstractCollectionpublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Setiterator in class AbstractCollectionpublic boolean remove(Object o)
remove in interface Collectionremove in interface Setremove in class AbstractCollectionpublic boolean containsAll(Collection c)
containsAll in interface CollectioncontainsAll in interface SetcontainsAll in class AbstractCollectionpublic boolean addAll(Collection c)
addAll in interface CollectionaddAll in interface SetaddAll in class AbstractCollectionpublic boolean removeAll(Collection c)
removeAll in interface CollectionremoveAll in interface SetremoveAll in class AbstractSetpublic boolean retainAll(Collection c)
retainAll in interface CollectionretainAll in interface SetretainAll in class AbstractCollectionpublic boolean add(Object o)
add in interface Collectionadd in interface Setadd in class AbstractCollection
public boolean add(int index,
Object o)
index - the index of object.o - the object to add.
public Object remove(int index)
index - the index of object.
public Object[] getArray()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||