Package dafny

Class Array<T>

java.lang.Object
dafny.Array<T>
Type Parameters:
T - The type of the elements in the array, or if that type is primitive, the boxed version of that type (e.g., Integer for int).
All Implemented Interfaces:
Cloneable

public final class Array<T> extends Object implements Cloneable
A wrapper for an array that may be of primitive type. Essentially acts as one "big box" for many primitives, as an alternative to putting each in their own box. Much faster than using Array operations to operate on possibly-primitive arrays. This isn't used by generated Dafny code, which directly uses values of type Object when the element type isn't known, relying on a TypeDescriptor passed in. It's much more pleasant to use, and more type-safe, than the bare TypeDescriptor operations, however, so extern implementors may be interested. It is also used to implement DafnySequence.
  • Method Details

    • newArray

      public static <T> Array<T> newArray(TypeDescriptor<T> eltType, int length)
    • fromList

      public static <T> Array<T> fromList(TypeDescriptor<T> eltType, List<T> elements)
    • elementType

      public TypeDescriptor<T> elementType()
    • unwrap

      public Object unwrap()
    • get

      public T get(int index)
    • set

      public void set(int index, T value)
    • length

      public int length()
    • fill

      public void fill(T value)
    • copy

      public Array<T> copy()
    • copy

      public void copy(int offset, Array<T> to, int toOffset, int length)
    • copyOfRange

      public Array<T> copyOfRange(int lo, int hi)
    • deepEquals

      public boolean deepEquals(Array<T> other)
    • wrap

      public static <T> Array<T> wrap(TypeDescriptor<T> eltType, Object array)
    • wrap

      public static <T> Array<T> wrap(TypeDescriptor<T> eltType, T[] array)
    • wrap

      public static Array<Byte> wrap(byte[] array)
    • wrap

      public static Array<Short> wrap(short[] array)
    • wrap

      public static Array<Integer> wrap(int[] array)
    • wrap

      public static Array<Long> wrap(long[] array)
    • wrap

      public static Array<Boolean> wrap(boolean[] array)
    • wrap

      public static Array<Character> wrap(char[] array)
    • unwrap

      public static Object unwrap(Array<?> array)
    • unwrapObjects

      public static <T> T[] unwrapObjects(Array<T> array)
    • unwrapBytes

      public static byte[] unwrapBytes(Array<Byte> array)
    • unwrapShorts

      public static short[] unwrapShorts(Array<Short> array)
    • unwrapInts

      public static int[] unwrapInts(Array<Integer> array)
    • unwrapLongs

      public static long[] unwrapLongs(Array<Long> array)
    • unwrapBooleans

      public static boolean[] unwrapBooleans(Array<Boolean> array)
    • unwrapChars

      public static char[] unwrapChars(Array<Character> array)