|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.sets.wrappers.AdapterFromJDKSet<V>
public class AdapterFromJDKSet<V>
| Constructor Summary | |
|---|---|
AdapterFromJDKSet(java.util.Set<V> map)
|
|
| 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. |
Set<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. |
V |
get(V key)
Returns the 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 parameter into the set, removing and returning any value equal to the parameter that was already present, as determined by the set's definition of equality. |
int |
putAll(java.lang.Iterable<V> vals)
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 val,
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 val,
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 |
size()
A convenience method returning the size of the set; this is equivalent to totalCount() or uniqueCount() |
int |
totalCount()
Returns the total number of values (including duplicates) in the set |
Set<V> |
unique()
Returns this |
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 AdapterFromJDKSet(java.util.Set<V> map)
| Method Detail |
|---|
public Set<V> copy()
SetSet
copy in interface AnySet<V>copy in interface Set<V>public V get(V key)
SetEquality or
Comparator. Returns null if no matching item is stored in the set. Equivalent to first(key)
get in interface Set<V>key - value to find
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)
Set
put in interface AnySet<V>put in interface Set<V>val - value to insert
public int size()
SettotalCount() or uniqueCount()
size in interface Set<V>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 int putAll(java.lang.Iterable<V> vals)
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>vals - 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 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 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 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.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 int totalCount()
AnyReadSet
totalCount in interface AnyReadSet<V>public Set<V> unique()
Setthis
unique in interface AnyReadSet<V>unique in interface AnySet<V>unique in interface Set<V>thispublic int uniqueCount()
AnyReadSet
uniqueCount in interface AnyReadSet<V>public java.util.Iterator<V> iterator()
iterator in interface java.lang.Iterable<V>public java.lang.Boolean apply(V v)
Function
apply in interface Function<V,java.lang.Boolean>v - something of type domain
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 val,
int removeAtMost)
AnySet
removeAndReturn in interface AnySet<V>val - the valueremoveAtMost - remove at most
public V removeAndReturnFirst(V val,
int removeAtMost)
AnySet
removeAndReturnFirst in interface AnySet<V>val - 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 | |||||||||