org.jjoost.collections
Interface Set<V>

All Superinterfaces:
AnyReadSet<V>, AnySet<V>, Function<V,java.lang.Boolean>, java.lang.Iterable<V>, java.io.Serializable
All Known Implementing Classes:
AbstractUniqueSetAdapter, AdapterFromJDKSet, ArraySet, HashSet, LockFreeHashSet, LockFreeLinkedScalarHashSet, SerialHashSet, SerialLinkedHashSet, SynchronizedSet

public interface Set<V>
extends AnySet<V>

This interface declares that a set supports precisely one occurence of each value

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
 Set<V> copy()
          Returns a copy of the set.
 V get(V find)
          Returns the value stored in the set that is equal to the provided value, as determined by any provided Equality or Comparator.
 V put(V value)
          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 size()
          A convenience method returning the size of the set; this is equivalent to totalCount() or uniqueCount()
 Set<V> unique()
          Returns this
 
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 value)
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.

Specified by:
put in interface AnySet<V>
Parameters:
value - value to insert
Returns:
value that was evicted from the set as a result of the action

get

V get(V find)
Returns the value stored in the set that is equal to the provided value, as determined by any provided Equality or Comparator. Returns null if no matching item is stored in the set. Equivalent to first(key)

Parameters:
find - value to find
Returns:
first matching value

size

int size()
A convenience method returning the size of the set; this is equivalent to totalCount() or uniqueCount()

Returns:
size of the set

copy

Set<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 return a Set

Specified by:
copy in interface AnySet<V>

unique

Set<V> unique()
Returns this

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