|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface AnySet<V>
This interface is the common ancestor of all modifiable Jjoost sets. The methods declared here make no assumptions about the number of occurences of a given value.
WARNING: Note that in a MultiSet the iterator() method will
return an Iterator that enumerates every occurence of every value. If you want
to get unique occurences of values, call the unique() method.
Also note that an Iterator returned by concurrent implementors of this class is permitted
to return values more times than they actually ever occurred if a valid sequence of deletes and inserts happens
to cause the Iterator to see the values multiple times. See the javadoc of the implementing classes
to determine their behaviour in this case.
| Method Summary | |
|---|---|
boolean |
add(V value)
Attempt to add the value to the set, returning false if the value could not be added, and true if it was. |
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. |
AnySet<V> |
copy()
Returns a copy of the set. |
V |
put(V value)
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> values)
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 value)
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. |
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. |
| Methods inherited from interface org.jjoost.collections.AnyReadSet |
|---|
all, contains, count, equality, first, isEmpty, list, permitsDuplicates, totalCount, uniqueCount |
| Methods inherited from interface java.lang.Iterable |
|---|
iterator |
| Methods inherited from interface org.jjoost.util.Function |
|---|
apply |
| Method Detail |
|---|
boolean add(V value)
false 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
value - value to insert
true if the set was modified, false otherwiseV put(V value)
Set 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
value - value to insert
int putAll(java.lang.Iterable<V> values)
put() 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.
values - values to insert
V putIfAbsent(V value)
null if an equal value does not already occur in the set; otherwise returns the first such
value encountered
value - value to insert
int remove(V value)
remove(value, Integer.MAX_VALUE).
value - remove equal to
int remove(V value,
int removeAtMost)
value - remove equal toremoveAtMost - remove at most
java.lang.Iterable<V> removeAndReturn(V value)
Iterable of the values removed. Equivalent to
removeAndReturn(value, Integer.MAX_VALUE).
value - remove equal to
java.lang.Iterable<V> removeAndReturn(V value,
int removeAtMost)
value - the valueremoveAtMost - remove at most
V removeAndReturnFirst(V value)
removeAndReturnFirst(value, Integer.MAX_VALUE).
value - remove
V removeAndReturnFirst(V value,
int removeAtMost)
value - removeremoveAtMost - remove at most
int clear()
java.util.Iterator<V> clearAndReturn()
Iterator 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.
AnySet<V> unique()
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.
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>void shrink()
AnySet<V> copy()
Set or MultiSet).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||