Package com.carrotsearch.hppc
Class Intrinsics
java.lang.Object
com.carrotsearch.hppc.Intrinsics
Intrinsic methods that are fully functional for the source templates
(generic) and are replaced with low-level corresponding equivalents for the
generated primitive types.
Whenever there is a generic type on a static method it can be used to parameterize
the given method based on the actual template type. Most intrinsics can guess their
generic template parameter (for example if the template has only one replaceable
type), but sometimes it may be necessary to provide the template type directly.
This class should not appear in the final distribution (all methods are
replaced in templates. Use forbidden-apis checker to make sure this is the
case.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Anything that implements value-equality function as replaced by theIntrinsics.EqualityFunction.equals(java.lang.Object, java.lang.Object)
intrinsic.static interface
Anything that distributes keys by their hash value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
add
(T op1, T op2) An intrinsic that is replaced with plain addition of arguments for primitive template types.static <T> T
A template cast to the given type T.static <T> T
empty()
Returns the default "empty key" (null
or0
for primitive types).static <T> boolean
equals
(Intrinsics.EqualityFunction delegate, Object e1, Object e2) Compare two keys for equivalence.static <T> boolean
Compare two keys for equivalence.static <T> boolean
Returnstrue
if the provided value is an "empty key" marker.static <T> T[]
newArray
(int arraySize) Creates an array for the given template type.
-
Constructor Details
-
Intrinsics
private Intrinsics()Everything static.
-
-
Method Details
-
isEmpty
Returnstrue
if the provided value is an "empty key" marker. For generic types the empty key isnull
, for any other type it is an equivalent of zero. Testing for zeros should be compiled into fast machine code. -
empty
public static <T> T empty()Returns the default "empty key" (null
or0
for primitive types). -
cast
A template cast to the given type T. With type erasure it should work internally just fine and it simplifies code. The cast will be erased for primitive types. -
newArray
public static <T> T[] newArray(int arraySize) Creates an array for the given template type. -
equals
Compare two keys for equivalence. Generic types are compared using the delegate function. Primitive types are compared using==
, except for floating-point types where they're compared by their actual representation bits as returned fromDouble.doubleToLongBits(double)
andFloat.floatToIntBits(float)
. -
equals
Compare two keys for equivalence. Generic types are compared for null-equivalence or usingObject.equals(Object)
. Primitive types are compared using==
, except for floating-point types where they're compared by their actual representation bits as returned fromDouble.doubleToLongBits(double)
andFloat.floatToIntBits(float)
. -
add
public static <T> T add(T op1, T op2) An intrinsic that is replaced with plain addition of arguments for primitive template types. Invalid for non-number generic types.
-