List of utility methods to do List Sub List
ArrayList | copySubList(final List Returns sub list with copied values. return new ArrayList<T>(list.subList(fromIndex, toIndex)); |
List | copySubList(List Unlike List.subList(), which returns a live view of a set of List elements, this method returns a new copy of the list. if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); if (toIndex > list.size()) throw new IndexOutOfBoundsException("toIndex = " + toIndex); if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); ArrayList<T> subList = new ArrayList<T>(); for (int i = fromIndex; i <= toIndex; i++) { ... |
List
| divideListInSublistsOfNSize(List divide List In Sublists Of N Size final List<List<T>> container = new ArrayList<>(); List<T> cList = new ArrayList<>(); for (T o : list) { cList.add(o); if (cList.size() == n) { container.add(cList); cList = new ArrayList<>(); if (cList != null && cList.size() > 0) { container.add(cList); return container; |
int[] | getIndexesId(List aList, List aSubList) Returns an array of indexes for given list and given objects in list. List<Integer> indexes = new ArrayList(); for (Object obj : aSubList) { int index = indexOfId(aList, obj); if (!indexes.contains(index)) indexes.add(index); int indxs[] = new int[indexes.size()]; for (int i = 0, iMax = indexes.size(); i < iMax; i++) ... |
List | getIndicesOfItems(List superList, List sublist) get Indices Of Items List<Integer> list = new ArrayList<Integer>(sublist.size()); for (Object object : sublist) { list.add(superList.indexOf(object)); return list; |
List | getRandomSubList(List get Random Sub List if ((percentage < 0) || (percentage > 1)) { throw new IllegalArgumentException("percentage has to be between 0 and 1"); int numberOfElements = (int) (inputList.size() * percentage); return getRandomSubList(inputList, numberOfElements); |
List | getSubList(int offset, int count, List get Sub List List<T> retVal = new ArrayList<T>(originalList); truncateList(offset, count, retVal); return retVal; |
List | getSubList(List entireList, Class cls) get report elements List list = new ArrayList(); for (Object e : entireList) { if (cls.isInstance(e)) list.add(cls.cast(e)); return list; |
List | getSubList(List list, Class type) Return all the classes in list which are of type. return getSubList(list, type, INCLUDE);
|
List | getSubList(List source, int nFrom, int nTo) get Sub List if (nFrom < 0) nFrom = 0; List list = new ArrayList(); for (int i = nFrom; i < (nTo + 1); ++i) { list.add(source.get(i)); return list; |