org.jjoost.collections
Interface MultiSet<V>

All Superinterfaces:
AnyReadSet<V>, AnySet<V>, Function<V,java.lang.Boolean>, java.lang.Iterable<V>, java.io.Serializable
All Known Implementing Classes:
InlineMultiHashSet, IterableSet, LockFreeCountingMultiHashSet, LockFreeInlineMultiHashSet, LockFreeLinkedCountingMultiHashSet, LockFreeLinkedInlineMultiHashSet, LockFreeLinkedNestedMultiHashSet, LockFreeNestedMultiHashSet, MultiArraySet, NestedMultiHashSet, SerialCountingMultiHashSet, SerialInlineMultiHashSet, SerialLinkedCountingMultiHashSet, SerialLinkedInlineMultiHashSet, SerialLinkedNestedMultiHashSet, SerialNestedMultiHashSet, SynchronizedMultiSet

public interface MultiSet<V>
extends AnySet<V>

This interface declares a set that supports multiple occurrences of each value

Note that 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.

Author:
b.elliottsmith

Method Summary
 MultiSet<V> copy()
          Returns a copy of the set.
 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.
 Set<V> unique()
          Returns a Set representing only the unique values present in this set.
 
Methods inherited from interface org.jjoost.collections.AnySet
add, clear, clearAndReturn, putAll, putIfAbsent, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, removeAndReturnFirst, shrink
 
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

put

V put(V val)
Insert the value into the set. This method will always succeed and the return value will always be null.

Specified by:
put in interface AnySet<V>
Parameters:
val - the val
Returns:
null

put

void put(V val,
         int numberOfTimes)
Insert the value into the set the specified number of times.

Parameters:
val - the val
numberOfTimes - the number of times

copy

MultiSet<V> copy()
Returns a copy of the set. This method may or may not return a set of the same class as the one it was called on, however must return a MultiSet

Specified by:
copy in interface AnySet<V>

unique

Set<V> unique()
Returns a Set 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.

Specified by:
unique in interface AnyReadSet<V>
Specified by:
unique in interface AnySet<V>
Returns:
unique values