|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.base.SynchronizedDelegator
org.jjoost.collections.sets.wrappers.SynchronizedArbitrarySet<V,S>
public class SynchronizedArbitrarySet<V,S extends AnySet<V>>
| Constructor Summary | |
|---|---|
SynchronizedArbitrarySet(S delegate)
|
|
| Method Summary | |
|---|---|
boolean |
add(V val)
Attempt to add the value to the set, returning false if the value could not be added, and true if it was. |
java.lang.Iterable<V> |
all(V value)
Returns an Iterable of all values contained in the set which are equal to the parameter, as determined by the set's
definition of equality. |
java.lang.Boolean |
apply(V v)
Returns the result of applying the function to the parameter |
int |
clear()
Removes all values from the set and return the number of values removed. |
java.util.Iterator<V> |
clearAndReturn()
Removes all values from the set and returns an Iterator over them. |
boolean |
contains(V value)
Returns a boolean indicating if the parameter occurs in the set at least once. |
AnySet<V> |
copy()
Returns a copy of the set. |
int |
count(V value)
Returns an integer representing the number of occurrences of the value in the set |
Equality<? super V> |
equality()
Returns an object that represents the definition of equality used by this set |
V |
first(V value)
The first value stored in the set that is equal to the provided value, as determined by any provided Equality or
Comparator. |
boolean |
isEmpty()
Indicates if the set is empty |
java.util.Iterator<V> |
iterator()
|
java.util.List<V> |
list(V value)
Returns a List of all values contained in the set which are equal to the parameter, as determined by the set's
definition of equality. |
boolean |
permitsDuplicates()
Indicates if the set permits a value to occur more than once |
V |
put(V val)
Insert the value into the set, returning any value that was evicted as a result or null if none (note that if the value to insert is null, the null returned cannot be used to determine if any action was taken on the set). |
int |
putAll(java.lang.Iterable<V> val)
Performs the equivalent of a put() operation for every value provided, returning an int representing the total number of
values that did not displace existing values. |
V |
putIfAbsent(V val)
Inserts the value and returns null if an equal value does not already occur in the set; otherwise returns the first such
value encountered |
int |
remove(V value)
Removes all occurrences of values equal to the parameter from the set, as determined by the set's definition of equality and returns the number of values that were removed from the set. |
int |
remove(V value,
int removeAtMost)
Removes at most the prescribed number of values equal to the parameter from the set; which values are removed is implementation specific, and may be arbitrary. |
java.lang.Iterable<V> |
removeAndReturn(V value)
Removes all occurrences of values equal to the parameter and returns an Iterable of the values removed. |
java.lang.Iterable<V> |
removeAndReturn(V value,
int removeAtMost)
Removes at most the prescribed number of values equal to the parameter from the set and returns them to the user; which values are removed is implementation specific, and may be arbitrary. |
V |
removeAndReturnFirst(V value)
Removes all occurrences of values equal to the parameter from the set, as determined by the set's definition of equality, and returns the first value encountered or null if none. |
V |
removeAndReturnFirst(V value,
int removeAtMost)
Removes at most the prescribed number of values equal to the parameter from the set and returns the first one encountered to the user, or null if none; which values are removed is implementation specific, and may be arbitrary. |
void |
shrink()
This method attempts to minimise the resource utilisation of the set. |
int |
totalCount()
Returns the total number of values (including duplicates) in the set |
AnySet<V> |
unique()
Returns an AnySet (usually a Set) representing only the unique values
present in this set; if this set is already unique this method should return the set itself. |
int |
uniqueCount()
Returns the number of unique values in the set |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SynchronizedArbitrarySet(S delegate)
| Method Detail |
|---|
public java.lang.Iterable<V> all(V value)
AnyReadSetIterable of all values contained in the set which are equal to the parameter, as determined by the set's
definition of equality.
Changes to the set that happen prior to retrieving an Iterator from the Iterable should be reflected in the
resulting Iterator. Changes to the set once an Iterator has been obtained may or may not be reflected in
the Iterator at the discretion of the implementing class.
In a concurrent set it is acceptable for values to occur extra times if they are deleted and re-inserted in between method calls on
the Iterator.
all in interface AnyReadSet<V>value - value to look for
public java.lang.Boolean apply(V v)
Function
apply in interface Function<V,java.lang.Boolean>v - something of type domain
public int clear()
AnySet
clear in interface AnySet<V>public java.util.Iterator<V> clearAndReturn()
AnySetIterator over them. This Iterator
must be exactly equal to the set of values removed from the set by the action, however this set of values
may not necessarily be determined, or the clear() completed, until the Iterator
has been exhausted.
clearAndReturn in interface AnySet<V>public boolean contains(V value)
AnyReadSetboolean indicating if the parameter occurs in the set at least once.
contains in interface AnyReadSet<V>value - value to look for
true, if presentpublic AnySet<V> copy()
AnySetSet or MultiSet).
copy in interface AnySet<V>public int count(V value)
AnyReadSet
count in interface AnyReadSet<V>value - value to look for
public V first(V value)
AnyReadSetEquality or
Comparator. Returns null if no matching item is stored in the set.
first in interface AnyReadSet<V>value - value to look for
public boolean isEmpty()
AnyReadSet
isEmpty in interface AnyReadSet<V>public java.util.Iterator<V> iterator()
iterator in interface java.lang.Iterable<V>public java.util.List<V> list(V value)
AnyReadSetList of all values contained in the set which are equal to the parameter, as determined by the set's
definition of equality. This list should be constructed "eagerly" and should be a consistent snapshot of the values valid at some
point between the method being called and it returning.
list in interface AnyReadSet<V>value - value to look for
public boolean permitsDuplicates()
AnyReadSet
permitsDuplicates in interface AnyReadSet<V>public boolean add(V val)
AnySetfalse if the value could not be added, and true if it was.
In a MultiSet the return value will always be true, however in a Set it will be
false if a value equal to the one provided (as determined by the set's definition of equality) was already present. For
values inequal to null, this is equivalent to put(value) == null
add in interface AnySet<V>val - value to insert
true if the set was modified, false otherwisepublic V put(V val)
AnySetSet any pre-existing value
that is equal to the parameter as determined by the set's definition of equality will be removed from the set and returned. In a
MultiSet the return value will always be null
put in interface AnySet<V>val - value to insert
public int putAll(java.lang.Iterable<V> val)
AnySetput() operation for every value provided, returning an int representing the total number of
values that did not displace existing values. In a MultiSet this will always be equal to the number of values provided,
however in a Set it may be fewer.
putAll in interface AnySet<V>val - values to insert
public V putIfAbsent(V val)
AnySetnull if an equal value does not already occur in the set; otherwise returns the first such
value encountered
putIfAbsent in interface AnySet<V>val - value to insert
public int remove(V value)
AnySetremove(value, Integer.MAX_VALUE).
remove in interface AnySet<V>value - remove equal to
public java.lang.Iterable<V> removeAndReturn(V value)
AnySetIterable of the values removed. Equivalent to
removeAndReturn(value, Integer.MAX_VALUE).
removeAndReturn in interface AnySet<V>value - remove equal to
public V removeAndReturnFirst(V value)
AnySetremoveAndReturnFirst(value, Integer.MAX_VALUE).
removeAndReturnFirst in interface AnySet<V>value - remove
public void shrink()
AnySet
shrink in interface AnySet<V>public int totalCount()
AnyReadSet
totalCount in interface AnyReadSet<V>public AnySet<V> unique()
AnySetAnySet (usually a Set) representing only the unique values
present in this set; if this set is already unique this method should return the set itself.
Changes to each set should be reflected in the other, however put() operations on the unique()
set will not be supported if the underlying set is not itself unique.
unique in interface AnyReadSet<V>unique in interface AnySet<V>public int uniqueCount()
AnyReadSet
uniqueCount in interface AnyReadSet<V>
public int remove(V value,
int removeAtMost)
AnySet
remove in interface AnySet<V>value - remove equal toremoveAtMost - remove at most
public java.lang.Iterable<V> removeAndReturn(V value,
int removeAtMost)
AnySet
removeAndReturn in interface AnySet<V>value - the valueremoveAtMost - remove at most
public V removeAndReturnFirst(V value,
int removeAtMost)
AnySet
removeAndReturnFirst in interface AnySet<V>value - removeremoveAtMost - remove at most
public Equality<? super V> equality()
AnyReadSet
equality in interface AnyReadSet<V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||