Class Intrinsics

java.lang.Object
com.carrotsearch.hppc.Intrinsics

public final class Intrinsics extends 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.
  • Constructor Details

    • Intrinsics

      private Intrinsics()
      Everything static.
  • Method Details

    • isEmpty

      public static <T> boolean isEmpty(Object value)
      Returns true if the provided value is an "empty key" marker. For generic types the empty key is null, 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 or 0 for primitive types).
    • cast

      public static <T> T cast(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, Object e1, 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 from Double.doubleToLongBits(double) and Float.floatToIntBits(float).
    • equals

      public static <T> boolean equals(Object e1, Object e2)
      Compare two keys for equivalence. Generic types are compared for null-equivalence or using Object.equals(Object). Primitive types are compared using ==, except for floating-point types where they're compared by their actual representation bits as returned from Double.doubleToLongBits(double) and Float.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.