public boolean moveToNew(int idx) {
        if (newLen == 0 || newList[newLen - 1] != idx) {
            // add item to newList first
            newList[newLen++] = idx;
        }

        // find idx in oldList, if removed successfully, return true.
        for (int i = 0; i < oldLen; i++) {
            if (oldList[i] == idx) {
                // Found the index in slot i:
                // delete the index from the old list.
                oldLen--;
                for (int j = i; j < oldLen; j++) {
                    oldList[j] = oldList[j + 1];
                }
                return true;
            }
        }
        return false;
    }
Adds an index to the new list.
If the index was not in the old list, false is returned,
if the index was in the old list, it is removed from the old
list and true is returned.

@param idx The index to move
@return True if it existed in old list and was removed
    from there, false otherwise.
jme3-core/src/main/java/com/jme3/renderer/IDList.java