Here you can find the source of moveToFront(List aList, Object anObj)
public static void moveToFront(List aList, Object anObj)
//package com.java2s; import java.util.*; public class Main { /**/* w w w . j a v a2 s.c om*/ * Moves the object at the given index to the front of the list. */ public static void moveToFront(List aList, int anIndex) { if (anIndex > 0) moveToFront(aList, aList.get(anIndex)); } /** * Move the given object to the front of the list. */ public static void moveToFront(List aList, Object anObj) { if (anObj != null) { aList.remove(anObj); aList.add(0, anObj); } } /** * Returns the object at the given index (returns null object for null list or invalid index). */ public static <T> T get(List<T> aList, int anIndex) { return aList == null || anIndex < 0 || anIndex >= aList.size() ? null : aList.get(anIndex); } /** * Removes given object from given list (accepts null list). */ public static boolean remove(List aList, Object anObj) { return aList == null ? false : aList.remove(anObj); } /** * Removes range of objects from given list (from start to end, not including end). */ public static void remove(List aList, int start, int end) { for (int i = end - 1; i >= start; i--) aList.remove(i); } /** * Adds an object to the given list and returns list (creates list if missing). */ public static <T> List<T> add(List<T> aList, T anObj) { // If list is null, create list if (aList == null) aList = new Vector(); // Add object aList.add(anObj); // Return list return aList; } /** * Returns the size of a list (accepts null list). */ public static int size(List aList) { return aList == null ? 0 : aList.size(); } }