org.jjoost.collections.sets.base
Class InlineMultiHashSet<V,N extends HashNode<N> & Value<V>>

java.lang.Object
  extended by org.jjoost.collections.sets.base.AbstractSet<V>
      extended by org.jjoost.collections.sets.base.AbstractHashSet<V,N>
          extended by org.jjoost.collections.sets.base.InlineMultiHashSet<V,N>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<V>, AnyReadSet<V>, AnySet<V>, MultiSet<V>, Function<V,java.lang.Boolean>
Direct Known Subclasses:
LockFreeInlineMultiHashSet, LockFreeLinkedInlineMultiHashSet, SerialInlineMultiHashSet, SerialLinkedInlineMultiHashSet

public class InlineMultiHashSet<V,N extends HashNode<N> & Value<V>>
extends AbstractHashSet<V,N>
implements MultiSet<V>

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jjoost.collections.sets.base.AbstractHashSet
AbstractHashSet.LockFreeHashSetNode<V>, AbstractHashSet.LockFreeHashSetNodeFactory<V>, AbstractHashSet.LockFreeLinkedHashSetNode<V>, AbstractHashSet.LockFreeLinkedHashSetNodeFactory<V>, AbstractHashSet.SerialHashSetNode<V>, AbstractHashSet.SerialHashSetNodeFactory<V>, AbstractHashSet.SerialLinkedHashSetNode<V>, AbstractHashSet.SerialLinkedHashSetNodeFactory<V>
 
Constructor Summary
InlineMultiHashSet(Rehasher rehasher, Equality<? super V> equality, HashNodeFactory<V,N> nodeFactory, HashStore<N> table)
           
 
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.
 MultiSet<V> copy()
          Returns a copy of the set.
 Equality<? super V> equality()
          Returns an object that represents the definition of equality used by this set
 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.
 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 org.jjoost.collections.sets.base.AbstractHashSet
all, apply, capacity, clear, clearAndReturn, contains, count, first, isEmpty, iterator, list, lockFreeLinkedNodeFactory, lockFreeNodeFactory, putAll, putIfAbsent, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, removeAndReturnFirst, resize, serialLinkedNodeFactory, serialNodeFactory, shrink, totalCount
 
Methods inherited from class org.jjoost.collections.sets.base.AbstractSet
equals, equals
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jjoost.collections.AnySet
clear, clearAndReturn, putAll, putIfAbsent, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, removeAndReturnFirst, shrink
 
Methods inherited from interface org.jjoost.collections.AnyReadSet
all, contains, count, first, isEmpty, list, totalCount
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.jjoost.util.Function
apply
 

Constructor Detail

InlineMultiHashSet

public InlineMultiHashSet(Rehasher rehasher,
                          Equality<? super V> equality,
                          HashNodeFactory<V,N> nodeFactory,
                          HashStore<N> table)
Method Detail

add

public boolean add(V val)
Description copied from interface: AnySet
Attempt to add the value to the set, returning false 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

Specified by:
add in interface AnySet<V>
Parameters:
val - value to insert
Returns:
true if the set was modified, false otherwise

put

public V put(V val)
Description copied from interface: MultiSet
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>
Specified by:
put in interface MultiSet<V>
Parameters:
val - the val
Returns:
null

put

public void put(V val,
                int count)
Description copied from interface: MultiSet
Insert the value into the set the specified number of times.

Specified by:
put in interface MultiSet<V>
Parameters:
val - the val
count - the number of times

copy

public MultiSet<V> copy()
Description copied from interface: MultiSet
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>
Specified by:
copy in interface MultiSet<V>

permitsDuplicates

public boolean permitsDuplicates()
Description copied from interface: AnyReadSet
Indicates if the set permits a value to occur more than once

Specified by:
permitsDuplicates in interface AnyReadSet<V>
Returns:
true, if successful

uniqueCount

public int uniqueCount()
Description copied from interface: AnyReadSet
Returns the number of unique values in the set

Specified by:
uniqueCount in interface AnyReadSet<V>
Returns:
number of unique values in the set

unique

public Set<V> unique()
Description copied from interface: MultiSet
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>
Specified by:
unique in interface MultiSet<V>
Returns:
unique values

equality

public Equality<? super V> equality()
Description copied from interface: AnyReadSet
Returns an object that represents the definition of equality used by this set

Specified by:
equality in interface AnyReadSet<V>
Overrides:
equality in class AbstractHashSet<V,N extends HashNode<N> & Value<V>>
Returns:
an object representing the equality used by this set