org.jjoost.collections
Class SetMaker.HashSetMaker<V>

java.lang.Object
  extended by org.jjoost.collections.SetMaker<V>
      extended by org.jjoost.collections.SetMaker.HashSetMaker<V>
Enclosing class:
SetMaker<V>

public static class SetMaker.HashSetMaker<V>
extends SetMaker<V>

This class provides a user friendly means of constructing a variety of hash sets. Almost all hash based set options are exposed by this class.

Author:
b.elliottsmith

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jjoost.collections.SetMaker
SetMaker.HashSetMaker<V>
 
Constructor Summary
SetMaker.HashSetMaker()
          create a new HashSetMaker
 
Method Summary
 SetMaker.HashSetMaker<V> copy()
          Return a new SetMaker with the same properties as this one
 SetMaker.HashSetMaker<V> equality(Equality<? super V> eq)
          Set the definition of equality used by sets constructed by this SetMaker.
 SetMaker.HashSetMaker<V> initialCapacity(int initialCapacity)
          Specify the minimum initial capacity a set should have on construction
 SetMaker.HashSetMaker<V> loadFactor(float loadFactor)
          Define the load factor all sets should be constructed with.
 MultiSet<V> newMultiSet(MultiSetNesting<V> nesting)
          Construct and return a new MultiSet with the provided nesting settings
 Set<V> newSet()
          Construct and return a new Set
 SetMaker.HashSetMaker<V> rehasher(Rehasher rehasher)
          Set the Rehasher used by sets constructed by this SetMaker.
 SetMaker.HashSetMaker<V> type(HashStoreType type)
          Set the type of hash structure to back the set by; this will affect performance and concurrency characteristics, primarily, but should have no impact on the basic functionality.
 
Methods inherited from class org.jjoost.collections.SetMaker
hash, newMultiSet, newMultiSetFactory, newSetFactory
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetMaker.HashSetMaker

public SetMaker.HashSetMaker()
create a new HashSetMaker

Method Detail

rehasher

public SetMaker.HashSetMaker<V> rehasher(Rehasher rehasher)
Set the Rehasher used by sets constructed by this SetMaker. All hashes are passed through the rehasher before being used; it is the rehasher's job to prevent unfortunate inputs/hash functions causing the set to perform poorly. The default differs depending on the HashStoreType.

Parameters:
rehasher - the Rehasher
Returns:
this

equality

public SetMaker.HashSetMaker<V> equality(Equality<? super V> eq)
Set the definition of equality used by sets constructed by this SetMaker. The Equality defines both the hash and equality implementations to use instead of the default Object.hashCode() and Object.equals() methods. The default is Equalities.object() which delegates to these methods, however Equalities.identity() causes sets created by this SetMaker to behave like an IdentityHashMap (regarding key equality).

Parameters:
eq - the key Equality
Returns:
this

type

public SetMaker.HashSetMaker<V> type(HashStoreType type)
Set the type of hash structure to back the set by; this will affect performance and concurrency characteristics, primarily, but should have no impact on the basic functionality.

Parameters:
type - the hash store type
Returns:
this

initialCapacity

public SetMaker.HashSetMaker<V> initialCapacity(int initialCapacity)
Specify the minimum initial capacity a set should have on construction

Parameters:
initialCapacity - the minimum initial capacity of the set constructed
Returns:
this

loadFactor

public SetMaker.HashSetMaker<V> loadFactor(float loadFactor)
Define the load factor all sets should be constructed with. This parameter is used to decide when to enlarge a hash structure, and will affect both the size and speed of the map. The smaller this value (less than 1) it is, the more space the map will waste but the better it will cope with poor distribution of elements. A perfect hash would need a value of 1 to perform optimally, but since most hash functions are not perfect, a value below 1 is usually best. A value above 1 will begin to save space at the expense of extra overhead maintaining and querying the map. If the size of the map is expected to stay relatively static, with the occasional peaks and troughs, however, a high load factor may avoid expensive and unnecessary grow operations.

Parameters:
loadFactor - the load factory of the map constructed
Returns:
this

newSet

public Set<V> newSet()
Description copied from class: SetMaker
Construct and return a new Set

Specified by:
newSet in class SetMaker<V>
Returns:
a new Set

newMultiSet

public MultiSet<V> newMultiSet(MultiSetNesting<V> nesting)
Description copied from class: SetMaker
Construct and return a new MultiSet with the provided nesting settings

Specified by:
newMultiSet in class SetMaker<V>
Parameters:
nesting - nesting
Returns:
a new MultiSet with the provided nesting settings

copy

public SetMaker.HashSetMaker<V> copy()
Description copied from class: SetMaker
Return a new SetMaker with the same properties as this one

Returns:
a copy of this SetMaker