Class Vectors

java.lang.Object
convex.core.data.Vectors

public class Vectors extends Object
Static utility functions for working with Vectors
  • Field Details

    • BITS_PER_LEVEL

      protected static final int BITS_PER_LEVEL
      See Also:
    • CHUNK_SIZE

      protected static final int CHUNK_SIZE
      See Also:
    • BITMASK

      protected static final int BITMASK
      See Also:
    • MAX_ENCODING_LENGTH

      public static final int MAX_ENCODING_LENGTH
  • Constructor Details

    • Vectors

      public Vectors()
  • Method Details

    • create

      public static <T extends ACell> AVector<T> create(ACell[] elements, int offset, int length)
      Creates a canonical AVector with the given elements
      Parameters:
      elements - Elements to include
      offset - Offset into element array
      length - Number of elements to take
      Returns:
      New vector with the specified elements
    • create

      public static <T extends ACell> AVector<T> create(ACell[] elements)
      Create a vector from an array of elements.
      Type Parameters:
      T - Type of elements
      Parameters:
      elements - Elements to include
      Returns:
      New vector with the specified elements
    • create

      public static <R extends ACell, T extends ACell> AVector<R> create(Collection<?> elements)
      Coerces a collection to a vector. Not necessarily the most efficient. Performs an unchecked cast.
      Type Parameters:
      R - Type of Vector elements to produce
      T - Type of source collection elements
      Parameters:
      elements - Elements to include
      Returns:
      New vector with the specified collection of elements
    • create

      public static <R extends ACell> AVector<R> create(ASequence<R> list)
      Creates a Vector from the contents of an arbitrary sequence
      Type Parameters:
      R - Type of sequence elements
      Parameters:
      list - Any sequential collection
      Returns:
      Vector of elements
    • empty

      public static <T extends ACell> AVector<T> empty()
    • of

      @SafeVarargs public static <T extends ACell> AVector<T> of(Object... elements)
      Creates a vector with the given values. Performs conversion to CVM types.
      Type Parameters:
      T - Type of elements (after CVM conversion)
      Parameters:
      elements - Elements to include
      Returns:
      New Vector
    • repeat

      public static <T extends ACell> AVector<T> repeat(T m, int count)
    • read

      public static <T extends ACell> AVector<T> read(ByteBuffer bb) throws BadFormatException
      Reads a Vector for the specified bytebuffer. Assumes Tag byte already consumed. Distinguishes between child types according to count.
      Type Parameters:
      T - Type of elements
      Parameters:
      bb - ByteBuffer to read from
      Returns:
      Vector read from ByteBuffer
      Throws:
      BadFormatException - If encoding is invalid