Create a new {@code Array} with the given length. The array is created
with the <i>default</i> {@code ObjectStore} object.

@param length the array length
@param <T> the array type
@return a new array with the given {@code length}
326154
public static <T> Array<T> ofLength(final int length) {
		return new Array<T>(ObjectStore.ofLength(length));
	}
686092
public static <T extends Number> int[] asArray(final T... array) {
        int[] b = new int[array.length];
        for (int i = 0; i < b.length; i++) {
            b[i] = array[i].intValue();
        }
        return b;
    }
1019788
private void resizeTo( int length )
    {
        if ( length <= 0 )
            throw new IllegalArgumentException("length <= 0");
        
        if ( length != buff.length ) {
            int len = ( length > buff.length ) ? buff.length : length;
            //System.out.println("resize:"+length);
            char[] obuff = buff;
            buff = new char[length];
            /*for ( int j = 0; j < len; j++ ) {
                buff[j] = obuff[j];
            }*/
            System.arraycopy(obuff, 0, buff, 0, len);
        }
    }
781735
public static Integer[] createAndInitializeArray(int size, Integer start) {
		Integer[] result = new Integer[size];
		for (int i = 0; i < result.length; i++) {
			result[i] = start++;
		}
		return result;
	}
789839
public static Codec<int[], EnumGene<Integer>> ofPermutation(final int length) {
		require.positive(length);

		return Codec.of(
			Genotype.of(PermutationChromosome.ofInteger(length)),
			gt -> gt.getChromosome().stream()
				.mapToInt(EnumGene::getAllele)
				.toArray()
		);
	}
758956
public static byte[] encodeLength(int length, int offset) {
        if (length < SIZE_THRESHOLD) {
            byte firstByte = (byte) (length + offset);
            return new byte[] { firstByte };
        } else if (length < MAX_ITEM_LENGTH) {
            byte[] binaryLength;
            if (length > 0xFF)
                binaryLength = intToBytesNoLeadZeroes(length);
            else
                binaryLength = new byte[] { (byte) length };
            byte firstByte = (byte) (binaryLength.length + offset + SIZE_THRESHOLD - 1);
            return concatenate(new byte[] { firstByte }, binaryLength);
        } else {
            throw new RuntimeException("Input too long");
        }
    }
860184
public void newarray(TypeMirror type, int count) throws IOException
    {
        if (type.getKind() != TypeKind.ARRAY)
        {
            throw new IllegalArgumentException(type+" is not array");
        }
        ArrayType at = (ArrayType) type;
        iconst(count);
        TypeMirror ct = at.getComponentType();
        switch (ct.getKind())
        {
            case BOOLEAN:
                newarray(T_BOOLEAN);
                break;
            case CHAR:
                newarray(T_CHAR);
                break;
            case FLOAT:
                newarray(T_FLOAT);
                break;
            case DOUBLE:
                newarray(T_DOUBLE);
                break;
            case BYTE:
                newarray(T_BYTE);
                break;
            case SHORT:
                newarray(T_SHORT);
                break;
            case INT:
                newarray(T_INT);
                break;
            case LONG:
                newarray(T_LONG);
                break;
            case DECLARED:
            {
                DeclaredType dt = (DeclaredType) ct;
                int index = subClass.resolveClassIndex((TypeElement)dt.asElement());
                anewarray(index);
            }
                break;
            default:
                throw new IllegalArgumentException(type+" not supported");
        }
    }
1114314
public static String createSequence(char c, int length) {
        if (length < 0) length = 1;

        StringBuffer buf = new StringBuffer(length);
        for (; length > 0; length--) {
            buf.append(c);
        }
        return buf.toString();
    }
159768
public byte[] generateRandomBytes(final int length) {
        byte[] result = new byte[length];
        for (int i = 0; i < length; i++) {
            result[i] = SEED[random.nextInt(SEED.length)];
        }
        return result;
    }
734301
public static String getSpaces(int length) {
        char[] charArray = new char[length];
        Arrays.fill(charArray, ' ');
        String str = new String(charArray);
        return str;
    }
297671
public final void setLengthForTree(int length) {
    this.length = length;

    for (Node child = first; child != null; child = child.next) {
      child.setLengthForTree(length);
    }
  }
412109
private static char[] copyOf(char[] original, int length) {
    char[] copy = new char[length];
    System.arraycopy(original, 0, copy, 0, Math.min(original.length, length));
    return copy;
  }
469945
private ObjectMetadata createMetadata(int length) {
        ObjectMetadata metadata = new ObjectMetadata();
        metadata.setContentLength(length);
        if (aes256Encryption)
            metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
        return metadata;
    }
1151379
public static IntArray getInstance(int[] buffer, int offset, int length)
    {
        return getInstance(IntBuffer.wrap(buffer, offset, length));
    }
1041294
public static Slice wrappedLongArray(long[] array, int offset, int length)
    {
        if (length == 0) {
            return EMPTY_SLICE;
        }
        return new Slice(array, offset, length);
    }
1002392
@Override
   public <T> T[] toArray(T[] a) {
      // Estimate size of array; be prepared to see more or fewer elements
      int size = size();
      T[] r = a.length >= size ? a :
            (T[])java.lang.reflect.Array
                  .newInstance(a.getClass().getComponentType(), size);
      try (CloseableIterator<O> it = iterator()) {
         for (int i = 0; i < r.length; i++) {
            if (! it.hasNext()) { // fewer elements than expected
               if (a == r) {
                  r[i] = null; // null-terminate
               } else if (a.length < i) {
                  return Arrays.copyOf(r, i);
               } else {
                  System.arraycopy(r, 0, a, 0, i);
                  if (a.length > i) {
                     a[i] = null;
                  }
               }
               return a;
            }
            r[i] = (T)it.next();
         }
         // more elements than expected
         return it.hasNext() ? finishToArray(r, it) : r;
      }
   }
1249427
public static <T> Set<T> arrayToSet(final T[] array) {
        if (null == array) {
            return Collections.emptySet();
        }

        final Set<T> ret = new HashSet<T>();

        for (int i = 0; i < array.length; i++) {
            final T object = array[i];

            ret.add(object);
        }

        return ret;
    }