Package com.carrotsearch.hppc
Class Intrinsics
- java.lang.Object
-
- com.carrotsearch.hppc.Intrinsics
-
public final class Intrinsics extends java.lang.Object
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 Classes Modifier and Type Class Description static interface
Intrinsics.EqualityFunction
Anything that implements value-equality function as replaced by theIntrinsics.EqualityFunction.equals(java.lang.Object, java.lang.Object)
intrinsic.static interface
Intrinsics.KeyHasher<T>
Anything that distributes keys by their hash value.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
add(T op1, T op2)
An intrinsic that is replaced with plain addition of arguments for primitive template types.static <T> T
cast(java.lang.Object value)
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, java.lang.Object e1, java.lang.Object e2)
Compare two keys for equivalence.static <T> boolean
equals(java.lang.Object e1, java.lang.Object e2)
Compare two keys for equivalence.static <T> boolean
isEmpty(java.lang.Object value)
Returnstrue
if the provided value is an "empty key" marker.static <T> T[]
newArray(int arraySize)
Creates an array for the given template type.
-
-
-
Method Detail
-
isEmpty
public static <T> boolean isEmpty(java.lang.Object value)
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
public static <T> T cast(java.lang.Object value)
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
public static <T> boolean equals(Intrinsics.EqualityFunction delegate, java.lang.Object e1, java.lang.Object e2)
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
public static <T> boolean equals(java.lang.Object e1, java.lang.Object e2)
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.
-
-