You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/08/25 23:40:55 UTC
(commons-collections) 15/18: Javadoc
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
commit 7bab3d26f2e54bcc51702647f2e50124feb7a5e5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 25 18:36:47 2024 -0400
Javadoc
---
.../collections4/list/AbstractLinkedList.java | 49 ++++++++++++++++++++--
.../collections4/map/AbstractHashedMap.java | 18 ++++++++
2 files changed, 63 insertions(+), 4 deletions(-)
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<E> implements List<E> {
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<E> implements List<E> {
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<E> implements List<E> {
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<E> implements List<E> {
return node.getValue();
}
+ /**
+ * Gets the first element.
+ *
+ * @return the first element.
+ */
public E getFirst() {
final Node<E> node = header.next;
if (node == header) {
@@ -779,6 +805,11 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return node.getValue();
}
+ /**
+ * Gets the last element.
+ *
+ * @return the last element.
+ */
public E getLast() {
final Node<E> node = header.previous;
if (node == header) {
@@ -958,6 +989,11 @@ public abstract class AbstractLinkedList<E> implements List<E> {
modCount++;
}
+ /**
+ * Removes the first element.
+ *
+ * @return The value removed.
+ */
public E removeFirst() {
final Node<E> node = header.next;
if (node == header) {
@@ -968,6 +1004,11 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return oldValue;
}
+ /**
+ * Removes the last element.
+ *
+ * @return The value removed.
+ */
public E removeLast() {
final Node<E> 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<K, V> extends AbstractMap<K, V> implements Iterab
this.expectedModCount = parent.modCount;
}
+ /**
+ * Gets the current entry.
+ *
+ * @return the current entry.
+ */
protected HashEntry<K, V> 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<K, V> nextEntry() {
if (parent.modCount != expectedModCount) {
throw new ConcurrentModificationException();
@@ -300,6 +315,9 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
return newCurrent;
}
+ /**
+ * Removes the current element.
+ */
public void remove() {
if (last == null) {
throw new IllegalStateException(REMOVE_INVALID);