Java Utililty Methods List Move Item

List of utility methods to do List Move Item

Description

The list of methods to do List Move Item are organized into topic(s).

Method

voidmoveRows(final List allRows, final List rowsToMove, final int index)
move Rows
final int oldBlockStart = allRows.indexOf(rowsToMove.get(0));
allRows.removeAll(rowsToMove);
if (index < oldBlockStart) {
    allRows.addAll(index, rowsToMove);
} else if (index > oldBlockStart) {
    allRows.addAll(index - rowsToMove.size() + 1, rowsToMove);
voidmoveToFront(List aList, Object anObj)
Move the given object to the front of the list.
if (anObj != null) {
    aList.remove(anObj);
    aList.add(0, anObj);
int[]moveTop(List list, int[] indices)
moves the selected items to the top.
int diff;
if (canMoveUp(list, indices)) {
    diff = indices[0];
    indices = moveItems(list, indices, diff, true);
return indices;
booleanmoveUp(final List list, final T toMoveUp)
move Up
boolean result = false;
if (list.size() >= 2) {
    int elemIndex = list.indexOf(toMoveUp);
    if (elemIndex > 0) {
        Collections.swap(list, elemIndex, elemIndex - 1);
        result = true;
return result;
voidmoveUp(List list, List toMoveUp)
move the given ones up in the specific list
List<Object> listCopy = new ArrayList<Object>(list.size());
for (Object object : list) {
    listCopy.add(object);
list.clear();
int count = listCopy.size();
Object current = null;
Object floating = null;
...
booleanmoveUp(List list, int[] selectionIndexes)
Move the selected items up one position in the list.
boolean moved = false;
int size = list.size();
for (int i = size - 1; i >= 0; i--) {
    T item = list.get(i);
    if (arrayContains(selectionIndexes, i)) {
        int nextUnselected = -1;
        int j = i - 1;
        while (j >= 0) {
...
booleanmoveUpInList(List list, int... indices)
move Up In List
if (isInArray(indices, 0)) {
    return false;
Arrays.sort(indices);
boolean changed = false;
for (int i : indices) {
    changed |= moveUpInListSingleEntry(list, i);
return changed;
booleanmoveUpInListSingleEntry(List list, int index)
move Up In List Single Entry
if (index == 0) {
    return false;
E element = list.remove(index);
list.add(index - 1, element);
return true;