package class1_3_ListAndArrayListJavadocOnly; import java.util.*; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; import java.util.stream.Stream; /** * This class extends LinkedList. * This is just to copy the Javadoc. * * To aid in the implementation of methods in this class, * Javadoc that would automatically be copied from List.java * during the generation of the web version is included here * * The Spec on Inheriting Comments * * @param The type of an element in this list */ public class BlankLinkedList extends LinkedList { /** * Appends the specified element to the end of this list. *

*

This method is equivalent to {@link java.util.LinkedList#addLast}. * * @param e element to be appended to this list * @return {@code true} (as specified by {@link java.util.Collection#add}) */ @Override public boolean add(E e) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Inserts the specified element at the specified position in this list. * Shifts the element currently at that position (if any) and any * subsequent elements to the right (adds one to their indices). * * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > size()) */ @Override public void add(int index, E element) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Removes all of the elements from this list. * The list will be empty after this call returns. */ @Override public void clear() { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns {@code true} if this list contains the specified element. * More formally, returns {@code true} if and only if this list contains * at least one element {@code e} such that * (o==null ? e==null : o.equals(e)). * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element */ @Override public boolean contains(Object o) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()) */ @Override public E get(int index) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns the index of the first occurrence of the specified element * in this list, or -1 if this list does not contain the element. * More formally, returns the lowest index {@code i} such that * (o==null ? get(i)==null : o.equals(get(i))), * or -1 if there is no such index. * * @param o element to search for * @return the index of the first occurrence of the specified element in * this list, or -1 if this list does not contain the element */ @Override public int indexOf(Object o) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns true if this list contains no elements. * * @return true if this list contains no elements */ @Override public boolean isEmpty() { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Removes the element at the specified position in this list. Shifts any * subsequent elements to the left (subtracts one from their indices). * Returns the element that was removed from the list. * * @param index the index of the element to be removed * @return the element previously at the specified position * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()) */ @Override public E remove(int index) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Removes the first occurrence of the specified element from this list, * if it is present. If this list does not contain the element, it is * unchanged. More formally, removes the element with the lowest index * {@code i} such that * (o==null ? get(i)==null : o.equals(get(i))) * (if such an element exists). Returns {@code true} if this list * contained the specified element (or equivalently, if this list * changed as a result of the call). * * @param o element to be removed from this list, if present * @return {@code true} if this list contained the specified element */ @Override public boolean remove(Object o) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Replaces the element at the specified position in this list with the * specified element. * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()) */ @Override public E set(int index, E element) { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ @Override public int size() { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns an array containing all of the elements in this list * in proper sequence (from first to last element). *

*

The returned array will be "safe" in that no references to it are * maintained by this list. (In other words, this method must allocate * a new array). The caller is thus free to modify the returned array. *

*

This method acts as bridge between array-based and collection-based * APIs. * * @return an array containing all of the elements in this list * in proper sequence */ @Override public Object[] toArray() { throw new UnsupportedOperationException("This method isn't written yet."); } /** * Returns an iterator over the elements in this list (in proper * sequence).

*

* This implementation merely returns a list iterator over the list. * * @return an iterator over the elements in this list (in proper sequence) */ @Override public Iterator iterator() { throw new UnsupportedOperationException("This method isn't written yet."); } //-------- METHODS BEYOND THIS POINT ARE NOT ALIGNED AND HAVE COMMENTS FROM // THE ARRAYLIST INSTEAD OF THE LINKEDLIST ------------ /** * Returns the index of the last occurrence of the specified element * in this list, or -1 if this list does not contain the element. * More formally, returns the highest index i such that * (o==null ? get(i)==null : o.equals(get(i))), * or -1 if there is no such index. * * @param o */ @Override public int lastIndexOf(Object o) { return super.lastIndexOf(o); } /** * Returns a shallow copy of this ArrayList instance. (The * elements themselves are not copied.) * * @return a clone of this ArrayList instance */ @Override public Object clone() { return super.clone(); } /** * Returns an array containing all of the elements in this list in proper * sequence (from first to last element); the runtime type of the returned * array is that of the specified array. If the list fits in the * specified array, it is returned therein. Otherwise, a new array is * allocated with the runtime type of the specified array and the size of * this list. *

*

If the list fits in the specified array with room to spare * (i.e., the array has more elements than the list), the element in * the array immediately following the end of the collection is set to * null. (This is useful in determining the length of the * list only if the caller knows that the list does not contain * any null elements.) * * @param a the array into which the elements of the list are to * be stored, if it is big enough; otherwise, a new array of the * same runtime type is allocated for this purpose. * @return an array containing the elements of the list * @throws ArrayStoreException if the runtime type of the specified array * is not a supertype of the runtime type of every element in * this list * @throws NullPointerException if the specified array is null */ @Override public T[] toArray(T[] a) { return super.toArray(a); } /** * Appends all of the elements in the specified collection to the end of * this list, in the order that they are returned by the * specified collection's Iterator. The behavior of this operation is * undefined if the specified collection is modified while the operation * is in progress. (This implies that the behavior of this call is * undefined if the specified collection is this list, and this * list is nonempty.) * * @param c collection containing elements to be added to this list * @return true if this list changed as a result of the call * @throws NullPointerException if the specified collection is null */ @Override public boolean addAll(Collection c) { return super.addAll(c); } /** * Inserts all of the elements in the specified collection into this * list, starting at the specified position. Shifts the element * currently at that position (if any) and any subsequent elements to * the right (increases their indices). The new elements will appear * in the list in the order that they are returned by the * specified collection's iterator. * * @param index index at which to insert the first element from the * specified collection * @param c collection containing elements to be added to this list * @return true if this list changed as a result of the call * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > size()) * @throws NullPointerException if the specified collection is null */ @Override public boolean addAll(int index, Collection c) { return super.addAll(index, c); } /** * Removes from this list all of the elements whose index is between * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive. * Shifts any succeeding elements to the left (reduces their index). * This call shortens the list by {@code (toIndex - fromIndex)} elements. * (If {@code toIndex==fromIndex}, this operation has no effect.) * * @param fromIndex * @param toIndex * @throws IndexOutOfBoundsException if {@code fromIndex} or * {@code toIndex} is out of range * ({@code fromIndex < 0 || * fromIndex >= size() || * toIndex > size() || * toIndex < fromIndex}) */ @Override protected void removeRange(int fromIndex, int toIndex) { super.removeRange(fromIndex, toIndex); } /** * Removes from this list all of its elements that are contained in the * specified collection. * * @param c collection containing elements to be removed from this list * @return {@code true} if this list changed as a result of the call * @throws ClassCastException if the class of an element of this list * is incompatible with the specified collection * (optional) * @throws NullPointerException if this list contains a null element and the * specified collection does not permit null elements * (optional), * or if the specified collection is null * @see java.util.Collection#contains(Object) */ @Override public boolean removeAll(Collection c) { return super.removeAll(c); } /** * Retains only the elements in this list that are contained in the * specified collection. In other words, removes from this list all * of its elements that are not contained in the specified collection. * * @param c collection containing elements to be retained in this list * @return {@code true} if this list changed as a result of the call * @throws ClassCastException if the class of an element of this list * is incompatible with the specified collection * (optional) * @throws NullPointerException if this list contains a null element and the * specified collection does not permit null elements * (optional), * or if the specified collection is null * @see java.util.Collection#contains(Object) */ @Override public boolean retainAll(Collection c) { return super.retainAll(c); } /** * Returns a list iterator over the elements in this list (in proper * sequence), starting at the specified position in the list. * The specified index indicates the first element that would be * returned by an initial call to {@link java.util.ListIterator#next next}. * An initial call to {@link java.util.ListIterator#previous previous} would * return the element with the specified index minus one. *

*

The returned list iterator is fail-fast. * * @param index * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public ListIterator listIterator(int index) { return super.listIterator(index); } /** * Returns a list iterator over the elements in this list (in proper * sequence). *

*

The returned list iterator is fail-fast. * * @see #listIterator(int) */ @Override public ListIterator listIterator() { return super.listIterator(); } /** * Returns a view of the portion of this list between the specified * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive. (If * {@code fromIndex} and {@code toIndex} are equal, the returned list is * empty.) The returned list is backed by this list, so non-structural * changes in the returned list are reflected in this list, and vice-versa. * The returned list supports all of the optional list operations. *

*

This method eliminates the need for explicit range operations (of * the sort that commonly exist for arrays). Any operation that expects * a list can be used as a range operation by passing a subList view * instead of a whole list. For example, the following idiom * removes a range of elements from a list: *

     *      list.subList(from, to).clear();
     * 
* Similar idioms may be constructed for {@link #indexOf(Object)} and * {@link #lastIndexOf(Object)}, and all of the algorithms in the * {@link java.util.Collections} class can be applied to a subList. *

*

The semantics of the list returned by this method become undefined if * the backing list (i.e., this list) is structurally modified in * any way other than via the returned list. (Structural modifications are * those that change the size of this list, or otherwise perturb it in such * a fashion that iterations in progress may yield incorrect results.) * * @param fromIndex * @param toIndex * @throws IndexOutOfBoundsException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} */ @Override public List subList(int fromIndex, int toIndex) { return super.subList(fromIndex, toIndex); } @Override public void forEach(Consumer action) { super.forEach(action); } /** * Creates a late-binding * and fail-fast {@link java.util.Spliterator} over the elements in this * list. *

*

The {@code Spliterator} reports {@link java.util.Spliterator#SIZED}, * {@link java.util.Spliterator#SUBSIZED}, and {@link java.util.Spliterator#ORDERED}. * Overriding implementations should document the reporting of additional * characteristic values. * * @return a {@code Spliterator} over the elements in this list * @since 1.8 */ @Override public Spliterator spliterator() { return super.spliterator(); } @Override public boolean removeIf(Predicate filter) { return super.removeIf(filter); } @Override public void replaceAll(UnaryOperator operator) { super.replaceAll(operator); } @Override public void sort(Comparator c) { super.sort(c); } /** * Compares the specified object with this list for equality. Returns * {@code true} if and only if the specified object is also a list, both * lists have the same size, and all corresponding pairs of elements in * the two lists are equal. (Two elements {@code e1} and * {@code e2} are equal if {@code (e1==null ? e2==null : * e1.equals(e2))}.) In other words, two lists are defined to be * equal if they contain the same elements in the same order.

*

* This implementation first checks if the specified object is this * list. If so, it returns {@code true}; if not, it checks if the * specified object is a list. If not, it returns {@code false}; if so, * it iterates over both lists, comparing corresponding pairs of elements. * If any comparison returns {@code false}, this method returns * {@code false}. If either iterator runs out of elements before the * other it returns {@code false} (as the lists are of unequal length); * otherwise it returns {@code true} when the iterations complete. * * @param o the object to be compared for equality with this list * @return {@code true} if the specified object is equal to this list */ @Override public boolean equals(Object o) { return super.equals(o); } /** * Returns the hash code value for this list. *

*

This implementation uses exactly the code that is used to define the * list hash function in the documentation for the {@link java.util.List#hashCode} * method. * * @return the hash code value for this list */ @Override public int hashCode() { return super.hashCode(); } /** * {@inheritDoc} *

*

This implementation iterates over the specified collection, * checking each element returned by the iterator in turn to see * if it's contained in this collection. If all elements are so * contained true is returned, otherwise false. * * @param c * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @see #contains(Object) */ @Override public boolean containsAll(Collection c) { return super.containsAll(c); } /** * Returns a string representation of this collection. The string * representation consists of a list of the collection's elements in the * order they are returned by its iterator, enclosed in square brackets * ("[]"). Adjacent elements are separated by the characters * ", " (comma and space). Elements are converted to strings as * by {@link String#valueOf(Object)}. * * @return a string representation of this collection */ @Override public String toString() { return super.toString(); } /** * Returns a sequential {@code Stream} with this collection as its source. *

*

This method should be overridden when the {@link #spliterator()} * method cannot return a spliterator that is {@code IMMUTABLE}, * {@code CONCURRENT}, or late-binding. (See {@link #spliterator()} * for details.) * * @return a sequential {@code Stream} over the elements in this collection * @implSpec The default implementation creates a sequential {@code Stream} from the * collection's {@code Spliterator}. * @since 1.8 */ @Override public Stream stream() { return null; } /** * Returns a possibly parallel {@code Stream} with this collection as its * source. It is allowable for this method to return a sequential stream. *

*

This method should be overridden when the {@link #spliterator()} * method cannot return a spliterator that is {@code IMMUTABLE}, * {@code CONCURRENT}, or late-binding. (See {@link #spliterator()} * for details.) * * @return a possibly parallel {@code Stream} over the elements in this * collection * @implSpec The default implementation creates a parallel {@code Stream} from the * collection's {@code Spliterator}. * @since 1.8 */ @Override public Stream parallelStream() { return null; } /** * Called by the garbage collector on an object when garbage collection * determines that there are no more references to the object. * A subclass overrides the {@code finalize} method to dispose of * system resources or to perform other cleanup. *

* The general contract of {@code finalize} is that it is invoked * if and when the Java™ virtual * machine has determined that there is no longer any * means by which this object can be accessed by any thread that has * not yet died, except as a result of an action taken by the * finalization of some other object or class which is ready to be * finalized. The {@code finalize} method may take any action, including * making this object available again to other threads; the usual purpose * of {@code finalize}, however, is to perform cleanup actions before * the object is irrevocably discarded. For example, the finalize method * for an object that represents an input/output connection might perform * explicit I/O transactions to break the connection before the object is * permanently discarded. *

* The {@code finalize} method of class {@code Object} performs no * special action; it simply returns normally. Subclasses of * {@code Object} may override this definition. *

* The Java programming language does not guarantee which thread will * invoke the {@code finalize} method for any given object. It is * guaranteed, however, that the thread that invokes finalize will not * be holding any user-visible synchronization locks when finalize is * invoked. If an uncaught exception is thrown by the finalize method, * the exception is ignored and finalization of that object terminates. *

* After the {@code finalize} method has been invoked for an object, no * further action is taken until the Java virtual machine has again * determined that there is no longer any means by which this object can * be accessed by any thread that has not yet died, including possible * actions by other objects or classes which are ready to be finalized, * at which point the object may be discarded. *

* The {@code finalize} method is never invoked more than once by a Java * virtual machine for any given object. *

* Any exception thrown by the {@code finalize} method causes * the finalization of this object to be halted, but is otherwise * ignored. * * @throws Throwable the {@code Exception} raised by this method * @jls 12.6 Finalization of Class Instances * @see java.lang.ref.WeakReference * @see java.lang.ref.PhantomReference */ @Override protected void finalize() throws Throwable { super.finalize(); } }