Terrier IR Platform
2.2.1

uk.ac.gla.terrier.utility
Class ArrayUtils

java.lang.Object
  extended by uk.ac.gla.terrier.utility.ArrayUtils

public class ArrayUtils
extends java.lang.Object

Handy methods for resizing arrays, and other handy array methods This is a fresh implementation of the capacity methods, without the use of any prelicensed code.

Version:
$Revision: 1.6 $
Author:
Ben He

Constructor Summary
ArrayUtils()
           
 
Method Summary
static byte[] ensureCapacity(byte[] array, int length)
          Grow an array to ensure it is the desired length.
static byte[] ensureCapacity(byte[] array, int length, int preserve)
          Grow an array to ensure it is the desired length.
static byte[] grow(byte[] array, int length)
          Grow an array to ensure it is at least the desired length.
static byte[] grow(byte[] array, int length, int preserve)
          Grow an array to ensure it is at least the desired length.
static java.lang.String join(java.lang.String[] in, java.lang.String join)
          Join some strings together.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtils

public ArrayUtils()
Method Detail

ensureCapacity

public static byte[] ensureCapacity(byte[] array,
                                    int length)
Grow an array to ensure it is the desired length.

Parameters:
array - input array
length - ensure array is this length
Returns:
new array with desired length

ensureCapacity

public static byte[] ensureCapacity(byte[] array,
                                    int length,
                                    int preserve)
Grow an array to ensure it is the desired length. Only copy the first preserve elements from the input array

Parameters:
array - input array
length - new desired length
preserve - amount of old array to copy to new array in case of reallocation
Returns:
new array with desired length

grow

public static byte[] grow(byte[] array,
                          int length)
Grow an array to ensure it is at least the desired length. The golden ratio is involved in the new length

Parameters:
array - input array
length - minimuim length of new array
Returns:
new array appropriately sized

grow

public static byte[] grow(byte[] array,
                          int length,
                          int preserve)
Grow an array to ensure it is at least the desired length. The golden ratio is involved in the new length. Only copy the first preserve elements from the input array.

Parameters:
array - input array
length - minimuim length of new array
Returns:
new array appropriately sized

join

public static java.lang.String join(java.lang.String[] in,
                                    java.lang.String join)
Join some strings together.

Parameters:
in - Strings to join
join - Character or String to join by

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow