diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java index 68353e82b..b6b4a99ee 100644 --- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java @@ -293,6 +293,9 @@ public abstract class AbstractLinkedList implements List { return true; } + /** + * Throws a {@link ConcurrentModificationException} if this instance fails its concurrency check. + */ protected void checkModCount() { if (parent.modCount != expectedModCount) { throw new ConcurrentModificationException(); @@ -329,6 +332,12 @@ public abstract class AbstractLinkedList implements List { return parent.createSubListListIterator(this, index); } + /** + * Throws an {@link IndexOutOfBoundsException} if the given indices are out of bounds. + * + * @param index lower index. + * @param beyond upper index. + */ protected void rangeCheck(final int index, final int beyond) { if (index < 0 || index >= beyond) { throw new IndexOutOfBoundsException("Index '" + index + "' out of bounds for size '" + size + "'"); @@ -583,13 +592,25 @@ public abstract class AbstractLinkedList implements List { return true; } - public boolean addFirst(final E o) { - addNodeAfter(header, o); + /** + * Adds an element at the beginning. + * + * @param e the element to beginning. + * @return true. + */ + public boolean addFirst(final E e) { + addNodeAfter(header, e); return true; } - public boolean addLast(final E o) { - addNodeBefore(header, o); + /** + * Adds an element at the end. + * + * @param e the element to add. + * @return true. + */ + public boolean addLast(final E e) { + addNodeBefore(header, e); return true; } @@ -771,6 +792,11 @@ public abstract class AbstractLinkedList implements List { return node.getValue(); } + /** + * Gets the first element. + * + * @return the first element. + */ public E getFirst() { final Node node = header.next; if (node == header) { @@ -779,6 +805,11 @@ public abstract class AbstractLinkedList implements List { return node.getValue(); } + /** + * Gets the last element. + * + * @return the last element. + */ public E getLast() { final Node node = header.previous; if (node == header) { @@ -958,6 +989,11 @@ public abstract class AbstractLinkedList implements List { modCount++; } + /** + * Removes the first element. + * + * @return The value removed. + */ public E removeFirst() { final Node node = header.next; if (node == header) { @@ -968,6 +1004,11 @@ public abstract class AbstractLinkedList implements List { return oldValue; } + /** + * Removes the last element. + * + * @return The value removed. + */ public E removeLast() { final Node node = header.previous; if (node == header) { diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java index fcc86d401..a47fe87b7 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java @@ -272,14 +272,29 @@ public class AbstractHashedMap extends AbstractMap implements Iterab this.expectedModCount = parent.modCount; } + /** + * Gets the current entry. + * + * @return the current entry. + */ protected HashEntry currentEntry() { return last; } + /** + * Tests whether there is a next entry. + * + * @return whether there is a next entry. + */ public boolean hasNext() { return next != null; } + /** + * Gets the next entry. + * + * @return the next entry. + */ protected HashEntry nextEntry() { if (parent.modCount != expectedModCount) { throw new ConcurrentModificationException(); @@ -300,6 +315,9 @@ public class AbstractHashedMap extends AbstractMap implements Iterab return newCurrent; } + /** + * Removes the current element. + */ public void remove() { if (last == null) { throw new IllegalStateException(REMOVE_INVALID);