Here you can find the source of pack(int count, Object[] array, AtomicReference
public static Object[] pack(int count, Object[] array, AtomicReference<Thread> edit, int idx)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.atomic.AtomicReference; public class Main { public static Object[] pack(int count, Object[] array, AtomicReference<Thread> edit, int idx) { Object[] newArray = new Object[2 * (count - 1)]; int j = 1; int bitmap = 0; for (int i = 0; i < idx; i++) if (array[i] != null) { newArray[j] = array[i];/* w ww . j a v a 2 s . c o m*/ bitmap |= 1 << i; j += 2; } for (int i = idx + 1; i < array.length; i++) if (array[i] != null) { newArray[j] = array[i]; bitmap |= 1 << i; j += 2; } Object[] returnArray = new Object[2]; returnArray[0] = bitmap; returnArray[1] = newArray; return returnArray; } }