Gets an array where array[i] = i.
@param length The length of the array.
@return The new index array.
484061
public static byte[] getIndexArray(int length) {
        byte[] index = new byte[length];
        for (int i=0; i<index.length; i++) {
            index[i] = (byte) i;
        }
        return index;
    }
1143698
public Slice slice(int index, int length)
    {
        if (index == 0 && length == this.length) {
            return this;
        }

        checkPositionIndexes(index, index + length, this.length);
        if (index >= 0 && length == 0) {
            return Slices.EMPTY_SLICE;
        }
        return new Slice(data, offset + index, length);
    }
377486
public Vector select(int[] indices) {
        int newLength = indices.length;

        if (newLength == 0) {
            fail("No elements selected.");
        }

        Vector result = blankOfLength(newLength);

        for (int i = 0; i < newLength; i++) {
            result.set(i, get(indices[i]));
        }

        return result;
    }
1114739
public String get(char[] array, int start, int length) {
		// Compute an arbitrary hash of the content
		int hashCode = 0;
		for (int i = start; i < start + length; i++) {
			hashCode = (hashCode * 31) + array[i];
		}

		// Pick a bucket using Doug Lea's supplemental secondaryHash function
		// (from HashMap)
		hashCode ^= (hashCode >>> 20) ^ (hashCode >>> 12);
		hashCode ^= (hashCode >>> 7) ^ (hashCode >>> 4);
		int index = hashCode & (pool.length - 1);

		String pooled = pool[index];
		if (pooled != null && contentEquals(pooled, array, start, length)) {
			return pooled;
		}

		String result = new String(array, start, length);
		pool[index] = result;
		return result;
	}
358595
public static ArrayList<String> toList( String[] array )
	{
		if( array == null )
		{
			return new ArrayList<String>( 0 );
		}
		ArrayList<String> list = new ArrayList<String>( array.length );
		for (String s : array)
		{
			list.add( s );
		}
		return list;
	}
1331814
public static Object toPrimitiveArray(Object array) {
    if (!array.getClass().isArray()) {
      throw new IllegalArgumentException("Must give array object.");
    }
    if (isWrapperArray(array.getClass())) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toPrimitive(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, Array.get(array, i));
      }
      return newArray;
    } else if (array.getClass().getComponentType().isArray()) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toPrimitiveArray(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toPrimitiveArray(Array.get(array, i)));
      }
      return newArray;
    }
    return array;
  }
113808
public static short sArrayGet(short[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
430073
private int getIndex(int ind) {

        // Try to find column index
        int i = Arrays.binarySearchGreater(index, ind, 0, used);

        // Found
        if (i < used && index[i] == ind)
            return i;

        int[] newIndex = index;
        double[] newData = data;

        // Check available memory
        if (++used > data.length) {

            // If zero-length, use new length of 1, else double the bandwidth
            int newLength = data.length != 0 ? data.length << 1 : 1;

            // Enforce the maximum size.
            newLength = Math.min(newLength, this.size);

            // Copy existing data into new arrays
            newIndex = new int[newLength];
            newData = new double[newLength];
            System.arraycopy(index, 0, newIndex, 0, i);
            System.arraycopy(data, 0, newData, 0, i);
        }

        // All ok, make room for insertion
        System.arraycopy(index, i, newIndex, i + 1, used - i - 1);
        System.arraycopy(data, i, newData, i + 1, used - i - 1);

        // Put in new structure
        newIndex[i] = ind;
        newData[i] = 0.;

        // Update pointers
        index = newIndex;
        data = newData;

        // Return insertion index
        return i;
    }
255496
public T[] createArray( int length ) {
		switch( family ) {
			case GRAY:
			case INTERLEAVED:
				return (T[])Array.newInstance(getImageClass(),length);

			case PLANAR:
				return (T[])new Planar[ length ];

			default:
				throw new IllegalArgumentException("Type not yet supported");
		}
	}
194262
public String[] getIndexArr() {
		String[] indexArr = new String[this.from.size()];
		for (int i = 0; i < indexArr.length; i++) {
			indexArr[i] = this.from.get(i).getIndex();
		}
		return indexArr;
	}
889351
public int[] get(int size) {
        if (array == null || size > array.length)
            return array = new int[size];

        return array;
    }
621137
public long[] readLongs (int length) throws KryoException {
		long[] array = new long[length];
		if (optional(length << 3) == length << 3) {
			byte[] buffer = this.buffer;
			int p = this.position;
			for (int i = 0; i < length; i++, p += 8) {
				array[i] = buffer[p] & 0xFF //
					| (buffer[p + 1] & 0xFF) << 8 //
					| (buffer[p + 2] & 0xFF) << 16 //
					| (long)(buffer[p + 3] & 0xFF) << 24 //
					| (long)(buffer[p + 4] & 0xFF) << 32 //
					| (long)(buffer[p + 5] & 0xFF) << 40 //
					| (long)(buffer[p + 6] & 0xFF) << 48 //
					| (long)buffer[p + 7] << 56;
			}
			position = p;
		} else {
			for (int i = 0; i < length; i++)
				array[i] = readLong();
		}
		return array;
	}
577306
public static String[] toStringArray(final Object array) {
        final int length = Array.getLength(array);
        final String[] result = new String[length];
        for (int i = 0; i < length; i++) {
            result[i] = Array.get(array, i).toString();
        }
        return result;
    }
1110421
public static IntegerMinMax[] newArray(int size) {
    IntegerMinMax[] ret = new IntegerMinMax[size];
    for(int i = 0; i < size; i++) {
      ret[i] = new IntegerMinMax();
    }
    return ret;
  }
1157877
public static long sizeOfArray(int length, long elementSize) {
        return roundTo(SPEC.getArrayHeaderSize() + length * elementSize, SPEC.getObjectPadding());
    }
1231956
public Slice slice(int index, int length)
    {
        if ((index == 0) && (length == length())) {
            return this;
        }
        checkIndexLength(index, length);
        if (length == 0) {
            return Slices.EMPTY_SLICE;
        }
        return new Slice(base, address + index, length, reference);
    }
861723
public ByteArray slice( int index, int length )
    {
        int oldLimit = bb.limit();
        bb.position( index );
        bb.limit( index + length );
        IoBuffer slice = bb.slice();
        bb.limit( oldLimit );
        return new BufferByteArray( slice )
        {

            @Override
            public void free()
            {
                // Do nothing.
            }
        };
    }