|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.sets.base.IterableSet<V>
public abstract class IterableSet<V>
| Constructor Summary | |
|---|---|
IterableSet()
|
|
| 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. |
MultiSet<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 |
abstract 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 |
abstract 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. |
void |
put(V val,
int numberOfTimes)
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 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 |
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 |
| Constructor Detail |
|---|
public IterableSet()
| Method Detail |
|---|
public abstract Equality<? super V> equality()
AnyReadSet
equality in interface AnyReadSet<V>public abstract 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 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 MultiSet<V> copy()
MultiSetMultiSet
copy in interface AnySet<V>copy in interface MultiSet<V>
public void put(V val,
int numberOfTimes)
MultiSet
put in interface MultiSet<V>val - the valnumberOfTimes - the number of timespublic 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 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,
int removeAtMost)
AnySet
remove in interface AnySet<V>value - remove equal toremoveAtMost - remove at most
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,
int removeAtMost)
AnySet
removeAndReturn in interface AnySet<V>value - the valueremoveAtMost - remove at most
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,
int removeAtMost)
AnySet
removeAndReturnFirst in interface AnySet<V>value - removeremoveAtMost - remove at most
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()
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 uniqueCount()
AnyReadSet
uniqueCount in interface AnyReadSet<V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||