Interface CompareFunc

All Superinterfaces:
FunctionPointer
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @Generated("org.javagi.JavaGI") public interface CompareFunc extends FunctionPointer

Functional interface declaration of the CompareFunc callback.

See Also:
  • Method Details

    • run

      int run(@Nullable MemorySegment a, @Nullable MemorySegment b)
      Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second.
      Parameters:
      a - a value
      b - a value to compare with
      Returns:
      negative value if a < b; zero if a = b; positive value if a > b
    • upcall

      default int upcall(MemorySegment a, MemorySegment b)
      The upcall method is called from native code. The parameters are marshaled and run(MemorySegment, MemorySegment) is executed.
    • toCallback

      default MemorySegment toCallback(Arena arena)
      Creates a native function pointer to the upcall(MemorySegment, MemorySegment) method.
      Specified by:
      toCallback in interface FunctionPointer
      Parameters:
      arena - the arena in which the function pointer is allocated
      Returns:
      the native function pointer