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

Type Parameters:
F - the concrete factory type which extends this interface
All Superinterfaces:
ContainerFactory<F>, HashContainerFactory<F>
All Known Subinterfaces:
HashObjByteMapFactory<K>, HashObjCharMapFactory<K>, HashObjDoubleMapFactory<K>, HashObjFloatMapFactory<K>, HashObjIntMapFactory<K>, HashObjLongMapFactory<K>, HashObjObjMapFactory<K,V>, HashObjSetFactory<E>, HashObjShortMapFactory<K>

public interface ObjHashFactory<F extends ObjHashFactory<F>>
extends HashContainerFactory<F>

Common configuration for factories of hash containers with Object keys.

Currently ObjHashFactory allows to specify only if null key is allowed or disallowed in hash containers, constructed by the factory. This is a performance hint: hash containers might, but aren't required to throw NullPointerException on putting null key, if null key is disallowed.

By default, null key is disallowed. Because in 99% of cases null key isn't possible (moreover, it is a bad practice to use null along with ordinary objects), on the other side, when null key is disallowed, substantial optimizations of hash table implementations become possible.

To construct hash containers which strictly follow HashMap and HashSet behaviour (these collections support null keys), you must configure the corresponding factory to allow null keys:

factory = factory.withNullKeyAllowed(true);

Koloboke Compile's counterpart of the withNullKeyAllowed() configuration is the @NullKeyAllowed annotation. An important difference is that ObjHashFactory doesn't guarantee that constructed containers throws NullPointerException to enforce the null key disallowance in runtime, while @NullKeyAllowed does guarantee that.


Method Summary
 boolean isNullKeyAllowed()
          Returns true if null key is allowed, false otherwise.
 F withNullKeyAllowed(boolean nullKeyAllowed)
          Returns a copy of this factory with null key allowed or disallowed, as specified.
 
Methods inherited from interface com.koloboke.collect.hash.HashContainerFactory
getHashConfig, withHashConfig
 
Methods inherited from interface com.koloboke.collect.ContainerFactory
getDefaultExpectedSize, withDefaultExpectedSize
 

Method Detail

isNullKeyAllowed

boolean isNullKeyAllowed()
Returns true if null key is allowed, false otherwise.

Default: false.

Returns:
true if null key is allowed, false otherwise

withNullKeyAllowed

F withNullKeyAllowed(boolean nullKeyAllowed)
Returns a copy of this factory with null key allowed or disallowed, as specified.

This is a performance hint: hash containers might, but aren't required to throw NullPointerException on putting null key, if null key is disallowed.

Parameters:
nullKeyAllowed - if null should be allowed in the containers contructed by the returned factory
Returns:
a copy of this factory with null key allowed or disallowed, as specified