com.koloboke.collect.hash
Interface CharHashFactory<F extends CharHashFactory<F>>

Type Parameters:
F - the concrete factory type which extends this interface
All Superinterfaces:
ContainerFactory<F>, HashContainerFactory<F>
All Known Subinterfaces:
HashCharByteMapFactory, HashCharCharMapFactory, HashCharDoubleMapFactory, HashCharFloatMapFactory, HashCharIntMapFactory, HashCharLongMapFactory, HashCharObjMapFactory<V>, HashCharSetFactory, HashCharShortMapFactory

public interface CharHashFactory<F extends CharHashFactory<F>>
extends HashContainerFactory<F>

Common configuration for factories of hash containers with char keys.

Currently CharHashFactory allows to specify consecutive range of keys which could be inserted into hash container - keys domain. This is a performance hint: hash containers might, but aren't required to throw IllegalArgumentException on inserting a key out of the keys domain.

By default, all keys are allowed (keys domain is a whole range of chars, from Character.MIN_VALUE to Character.MAX_VALUE.

For example, map keys or elements of the set could be unique IDs, counting from 1, thus it's guaranteed that these keys are positive. Or one specific key has a special meaning in the logic of your application. When you are sure that some keys range could never be put into hash container, it is recommended to configure corresponding factory, which extends this interface, with complement of that range as keys domain (or, alternatively, with that range as keys domain complement).

It's OK to specify keys domain which include some actually impossible keys, but you shouldn't leave a single valid key out of the domain. If the set of possible (impossible) keys consist of several ranges, and/or standalone keys, it is still recommended to specify the domain to "forbid" some impossible keys. For example, if possible keys are printable characters, you should exclude first eight non-printable characters prior to \t (tab character):

factory = factory.withKeysDomain('\t', Character.MAX_VALUE);


Method Summary
 char getLowerKeyDomainBound()
          Returns lower (inclusive) bound of keys domain.
 char getUpperKeyDomainBound()
          Returns upper (inclusive) bound of keys domain.
 F withKeysDomain(char minPossibleKey, char maxPossibleKey)
          Returns a copy of this factory with keys domain set to the specified range.
 F withKeysDomainComplement(char minImpossibleKey, char maxImpossibleKey)
          Returns a copy of this factory with keys domain set to the complement of the specified range.
 
Methods inherited from interface com.koloboke.collect.hash.HashContainerFactory
getHashConfig, withHashConfig
 
Methods inherited from interface com.koloboke.collect.ContainerFactory
getDefaultExpectedSize, withDefaultExpectedSize
 

Method Detail

getLowerKeyDomainBound

char getLowerKeyDomainBound()
Returns lower (inclusive) bound of keys domain.

Default: Character.MIN_VALUE.

Returns:
lower (inclusive) bound of keys domain

getUpperKeyDomainBound

char getUpperKeyDomainBound()
Returns upper (inclusive) bound of keys domain.

Default: Character.MAX_VALUE.

Returns:
upper (inclusive) bound of keys domain

withKeysDomain

F withKeysDomain(char minPossibleKey,
                 char maxPossibleKey)
Returns a copy of this factory with keys domain set to the specified range.

This is a performance hint: hash containers might, but aren't required to throw IllegalArgumentException on putting key out of the keys domain.

Example:

 // only positive keys
 factory = factory.withKeysDomain((char) 1, Character.MAX_VALUE);

Parameters:
minPossibleKey - lower (inclusive) bound of the target keys domain
maxPossibleKey - upper (inclusive) bound of the target keys domain
Returns:
a copy of this factory with keys domain set to the specified range
Throws:
IllegalArgumentException - if minPossibleKey is greater than maxPossibleKey

withKeysDomainComplement

F withKeysDomainComplement(char minImpossibleKey,
                           char maxImpossibleKey)
Returns a copy of this factory with keys domain set to the complement of the specified range.

This is a performance hint: hash containers might, but aren't required to throw IllegalArgumentException on putting key out of the keys domain.

This method is needed to specify keys domain that include both Character.MIN_VALUE and Character.MAX_VALUE, but with a "hole" somewhere in between. Providing a single withKeysDomain(char, char) method for this and "ordinary" keys domain application is error-prone, because there is no way to distinguish intention (domain with a "hole") and mistakenly reordered arguments while attempting to specify "ordinary" domain.

Example:

 // any keys except EOF
 factory = factory.withKeysDomainComplement('', '');

Parameters:
minImpossibleKey - upper (exclusive) bound of the target keys domain
maxImpossibleKey - lower (exclusive) bound of the target keys domain
Returns:
a copy of this factory with keys domain set to the complement of the specified range
Throws:
IllegalArgumentException - if minImpossibleKey is greater than maxImpossibleKey