--- old/src/java.base/share/classes/java/util/List.java 2015-02-04 10:44:11.476941301 +0100 +++ new/src/java.base/share/classes/java/util/List.java 2015-02-04 10:44:11.377943137 +0100 @@ -23,9 +23,11 @@ * questions. */ -package java.util; +package javany.util; -import java.util.function.UnaryOperator; +import javany.util.function.UnaryOperator; + +import java.util.Objects; /** * An ordered collection (also known as a sequence). The user of this @@ -108,7 +110,7 @@ * @since 1.2 */ -public interface List extends Collection { +public interface List extends Collection { // Query Operations /** @@ -208,7 +210,7 @@ * this list * @throws NullPointerException if the specified array is null */ - T[] toArray(T[] a); + T[] toArray(T[] a); // Modification Operations @@ -474,12 +476,12 @@ */ @SuppressWarnings({"unchecked", "rawtypes"}) default void sort(Comparator c) { - Object[] a = this.toArray(); - Arrays.sort(a, (Comparator) c); + E[] a = this.toArray(new E[size()]); + Arrays.sort(a, c); ListIterator i = this.listIterator(); - for (Object e : a) { + for (E e : a) { i.next(); - i.set((E) e); + i.set(e); } } @@ -621,6 +623,14 @@ */ int indexOf(Object o); + default int indexOfElement(E e) { + ListIterator it = listIterator(); + while (it.hasNext()) + if (Any.equals(e, it.next())) + return it.previousIndex(); + return -1; + } + /** * Returns the index of the last occurrence of the specified element * in this list, or -1 if this list does not contain the element. @@ -640,6 +650,13 @@ */ int lastIndexOf(Object o); + default int lastIndexOfElement(E e) { + ListIterator it = listIterator(size()); + while (it.hasPrevious()) + if (Any.equals(e, it.previous())) + return it.nextIndex(); + return -1; + } // List Iterators @@ -727,8 +744,8 @@ * @return a {@code Spliterator} over the elements in this list * @since 1.8 */ - @Override - default Spliterator spliterator() { - return Spliterators.spliterator(this, Spliterator.ORDERED); - } +// @Override +// default Spliterator spliterator() { +// return Spliterators.spliterator(this, Spliterator.ORDERED); +// } }