MCPcopy Create free account
hub / github.com/davidgiven/luje / reverse

Method reverse

lib/java/util/Collections.java:1787–1799  ·  view source on GitHub ↗

Modifies the specified List by reversing the order of the elements. @param list the list to reverse. @throws UnsupportedOperationException when replacing an element in the List is not supported.

(List<?> list)

Source from the content-addressed store, hash-verified

1785 * when replacing an element in the List is not supported.
1786 */
1787 @SuppressWarnings("unchecked")
1788 public static void reverse(List<?> list) {
1789 int size = list.size();
1790 ListIterator<Object> front = (ListIterator<Object>) list.listIterator();
1791 ListIterator<Object> back = (ListIterator<Object>) list
1792 .listIterator(size);
1793 for (int i = 0; i < size / 2; i++) {
1794 Object frontNext = front.next();
1795 Object backPrev = back.previous();
1796 front.set(backPrev);
1797 back.set(frontNext);
1798 }
1799 }
1800
1801 /**
1802 * A comparator which reverses the natural order of the elements. The

Callers 1

rotateMethod · 0.95

Calls 5

sizeMethod · 0.65
listIteratorMethod · 0.65
nextMethod · 0.65
previousMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected