F
- the concrete factory type which extends this interfacepublic interface ObjHashFactory<F extends ObjHashFactory<F>> extends HashContainerFactory<F>
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.
Modifier and Type | Method and Description |
---|---|
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. |
getHashConfig, withHashConfig
getDefaultExpectedSize, withDefaultExpectedSize
boolean isNullKeyAllowed()
true
if null
key is allowed, false
otherwise.
Default: false
.
true
if null key is allowed, false
otherwiseF withNullKeyAllowed(boolean nullKeyAllowed)
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.
nullKeyAllowed
- if null
should be allowed in the containers contructed
by the returned factorynull
key allowed or disallowed, as specified