|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.sets.base.NestedMultiHashSet<V,N>
public class NestedMultiHashSet<V,N extends HashNode<N> & NestedMultiHashSet.INode<V,N>>
| Nested Class Summary | |
|---|---|
static interface |
NestedMultiHashSet.INode<V,N extends HashNode<N> & NestedMultiHashSet.INode<V,N>>
|
static class |
NestedMultiHashSet.ValueEquality<V,N extends HashNode<N> & NestedMultiHashSet.INode<V,N>>
|
| 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 val)
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 val)
Returns a boolean indicating if the parameter occurs in the set at least once. |
MultiSet<V> |
copy()
Returns a copy of the set. |
int |
count(V val)
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 val)
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 val)
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. |
void |
put(V val,
int count)
Insert the value into the set the specified number of times. |
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 val)
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 val,
int atMost)
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 val)
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 atMost)
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 val)
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 atMost)
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 |
Set<V> |
unique()
Returns a Set representing only the unique values present in this set. |
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 |
| Method Detail |
|---|
public Equality<? super V> equality()
AnyReadSet
equality in interface AnyReadSet<V>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)
MultiSet
put in interface AnySet<V>put in interface MultiSet<V>val - the val
public void put(V val,
int count)
MultiSet
put in interface MultiSet<V>val - the valcount - the number of timespublic 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 val)
AnySetremove(value, Integer.MAX_VALUE).
remove in interface AnySet<V>val - remove equal to
public V removeAndReturnFirst(V val)
AnySetremoveAndReturnFirst(value, Integer.MAX_VALUE).
removeAndReturnFirst in interface AnySet<V>val - remove
public java.lang.Iterable<V> removeAndReturn(V val)
AnySetIterable of the values removed. Equivalent to
removeAndReturn(value, Integer.MAX_VALUE).
removeAndReturn in interface AnySet<V>val - remove equal to
public int remove(V val,
int atMost)
AnySet
remove in interface AnySet<V>val - remove equal toatMost - remove at most
public V removeAndReturnFirst(V val,
int atMost)
AnySet
removeAndReturnFirst in interface AnySet<V>val - removeatMost - remove at most
public java.lang.Iterable<V> removeAndReturn(V val,
int atMost)
AnySet
removeAndReturn in interface AnySet<V>val - the valueatMost - remove at most
public boolean contains(V val)
AnyReadSetboolean indicating if the parameter occurs in the set at least once.
contains in interface AnyReadSet<V>val - value to look for
true, if presentpublic int count(V val)
AnyReadSet
count in interface AnyReadSet<V>val - value to look for
public void shrink()
AnySet
shrink in interface AnySet<V>public V first(V val)
AnyReadSetEquality or
Comparator. Returns null if no matching item is stored in the set.
first in interface AnyReadSet<V>val - value to look for
public java.util.List<V> list(V val)
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>val - value to look for
public int totalCount()
AnyReadSet
totalCount in interface AnyReadSet<V>public int uniqueCount()
AnyReadSet
uniqueCount in interface AnyReadSet<V>public boolean isEmpty()
AnyReadSet
isEmpty in interface AnyReadSet<V>public java.lang.Iterable<V> all(V val)
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>val - value to look for
public MultiSet<V> copy()
MultiSetMultiSet
copy in interface AnySet<V>copy in interface MultiSet<V>public Set<V> unique()
MultiSetSet representing only the unique values present in this set.
Changes to each set should be reflected in the other, however put() operations on the unique()
set are not supported.
unique in interface AnyReadSet<V>unique in interface AnySet<V>unique in interface MultiSet<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 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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||