|
| 1 | +package me.ramswaroop.common; |
| 2 | + |
| 3 | +/** |
| 4 | + * Created by IntelliJ IDEA. |
| 5 | + * |
| 6 | + * @author: ramswaroop |
| 7 | + * @date: 6/16/15 |
| 8 | + * @time: 12:53 PM |
| 9 | + */ |
| 10 | +public interface LinkedList<E> { |
| 11 | + |
| 12 | + /** |
| 13 | + * Appends the specified element to the end of this list. |
| 14 | + * |
| 15 | + * @param item |
| 16 | + * @return |
| 17 | + */ |
| 18 | + boolean add(E item); |
| 19 | + |
| 20 | + /** |
| 21 | + * Inserts the specified element at the specified position in this list. |
| 22 | + * |
| 23 | + * @param index |
| 24 | + * @param item |
| 25 | + * @return |
| 26 | + * @throws IndexOutOfBoundsException {@inheritDoc} |
| 27 | + */ |
| 28 | + boolean add(int index, E item); |
| 29 | + |
| 30 | + /** |
| 31 | + * Inserts the specified element at the beginning of this list. |
| 32 | + * |
| 33 | + * @param item |
| 34 | + */ |
| 35 | + void addFirst(E item); |
| 36 | + |
| 37 | + /** |
| 38 | + * Appends the specified element to the end of this list. |
| 39 | + * |
| 40 | + * @param item |
| 41 | + */ |
| 42 | + void addLast(E item); |
| 43 | + |
| 44 | + /** |
| 45 | + * Removes all of the elements from this list. |
| 46 | + */ |
| 47 | + void clear(); |
| 48 | + |
| 49 | + /** |
| 50 | + * Returns a shallow copy of this LinkedList. |
| 51 | + * |
| 52 | + * @return |
| 53 | + */ |
| 54 | + LinkedList<E> clone(); |
| 55 | + |
| 56 | + /** |
| 57 | + * Returns true if this list contains the specified element. |
| 58 | + * |
| 59 | + * @param item |
| 60 | + * @return |
| 61 | + */ |
| 62 | + boolean contains(E item); |
| 63 | + |
| 64 | + /** |
| 65 | + * Returns the element at the specified position in this list. |
| 66 | + * |
| 67 | + * @param index |
| 68 | + * @return |
| 69 | + * @throws IndexOutOfBoundsException {@inheritDoc} |
| 70 | + */ |
| 71 | + E get(int index); |
| 72 | + |
| 73 | + /** |
| 74 | + * Returns the first element in this list. |
| 75 | + * |
| 76 | + * @return |
| 77 | + * @throws java.util.NoSuchElementException if this list is empty |
| 78 | + */ |
| 79 | + E getFirst(); |
| 80 | + |
| 81 | + /** |
| 82 | + * Returns the last element in this list. |
| 83 | + * |
| 84 | + * @return |
| 85 | + * @throws java.util.NoSuchElementException if this list is empty |
| 86 | + */ |
| 87 | + E getLast(); |
| 88 | + |
| 89 | + /** |
| 90 | + * Retrieves and removes the head (first element) of this list. |
| 91 | + * |
| 92 | + * @return |
| 93 | + */ |
| 94 | + E remove(); |
| 95 | + |
| 96 | + /** |
| 97 | + * Removes the element at the specified position in this list. |
| 98 | + * |
| 99 | + * @param index |
| 100 | + * @return |
| 101 | + * @throws IndexOutOfBoundsException {@inheritDoc} |
| 102 | + */ |
| 103 | + E remove(int index); |
| 104 | + |
| 105 | + /** |
| 106 | + * Removes the first occurrence of the specified element from this list, if it is present. |
| 107 | + * |
| 108 | + * @param item |
| 109 | + * @return {@code true} if this list contained the specified element |
| 110 | + */ |
| 111 | + boolean remove(E item); |
| 112 | + |
| 113 | + /** |
| 114 | + * Replaces the element at the specified position in this list with the specified element. |
| 115 | + * |
| 116 | + * @param index |
| 117 | + * @param item |
| 118 | + * @return |
| 119 | + * @throws IndexOutOfBoundsException {@inheritDoc} |
| 120 | + */ |
| 121 | + E set(int index, E item); |
| 122 | + |
| 123 | + /** |
| 124 | + * Returns the number of elements in this list. |
| 125 | + * |
| 126 | + * @return |
| 127 | + */ |
| 128 | + int size(); |
| 129 | + |
| 130 | +} |
0 commit comments