コード例 #1
0
 /**
  * Creates a new array with from copying oldA and removing 'length' entries at position pos. The
  * old array is returned to the pool.
  *
  * @param oldA old array
  * @param dstPos destination
  * @param length length
  * @return new array
  */
 public static long[] arrayRemove(long[] oldA, int dstPos, int length) {
   long[] ret = arrayCreate(oldA.length - length);
   arraycopy(oldA, 0, ret, 0, dstPos);
   arraycopy(oldA, dstPos + length, ret, dstPos, ret.length - dstPos);
   POOL.offer(oldA);
   return ret;
 }
コード例 #2
0
 /**
  * Reads a long array from a stream.
  *
  * @param in input stream
  * @return the long array.
  * @throws IOException if reading fails
  */
 public static long[] read(ObjectInput in) throws IOException {
   int size = in.readInt();
   long[] ret = POOL.getArray(size);
   for (int i = 0; i < size; i++) {
     ret[i] = in.readLong();
   }
   return ret;
 }
コード例 #3
0
 /**
  * Creates a new array with from copying oldA and inserting insertA at position pos. The old array
  * is returned to the pool.
  *
  * @param oldA old array
  * @param insertA array to insert
  * @param dstPos destination position
  * @return new array
  */
 public static long[] insertArray(long[] oldA, long[] insertA, int dstPos) {
   long[] ret = arrayCreate(oldA.length + insertA.length);
   arraycopy(oldA, 0, ret, 0, dstPos);
   arraycopy(insertA, 0, ret, dstPos, insertA.length);
   arraycopy(oldA, dstPos, ret, dstPos + insertA.length, oldA.length - dstPos);
   POOL.offer(oldA);
   return ret;
 }
コード例 #4
0
 /**
  * Replaces an array with another array. The replaced array is returned to the pool.
  *
  * @param oldA old array
  * @param newA new array
  * @return new array
  */
 public static long[] arrayReplace(long[] oldA, long[] newA) {
   if (oldA != null) {
     POOL.offer(oldA);
   }
   return newA;
 }
コード例 #5
0
 /**
  * Create an array.
  *
  * @param size size
  * @return a new array
  */
 public static long[] arrayCreate(int size) {
   return POOL.getArray(calcArraySize(size));
 }