Interface ArrayWritable<T>

  • Type Parameters:
    T - type class. This is a marker parameter that is not reflected in the signatures, but can be respected by methods requiring type information.

    public interface ArrayWritable<T>
    Unified interface for (collection) classes that allow writing their contents to an array. The intended behavior differs from the standard Java Collection.toArray(Object[]) method in the following way:
    • It is possible to specify a source offset for this collection, i.e., how many elements are skipped before the target array is written to. Note that if the collection does not define an iteration order, the set of elements which are omitted is unspecified if offset > 0.
    • It is possible to specify an offset for the destination array, i.e., at which position to begin writing into the destination array.
    • It is possible to specify the number of elements to be written. Again, if this collection does not define an iteration order, the set of elements which are omitted if num < size() is unspecified.
    • Method Detail

      • writeToArray

        void writeToArray​(int offset,
                          @Nullable Object[] array,
                          int tgtOfs,
                          int num)
        Writes the contents of this container to an array. The behavior of calling this method should be equivalent to System.arraycopy(this.toArray(), offset, array, tgtOfs, num);
        Parameters:
        offset - how many elements of this container to skip.
        array - the array in which to store the elements.
        tgtOfs - the starting offset in the target array.
        num - the maximum number of elements to copy.
      • size

        int size()
        The size of this container.