summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-04-07 16:06:18 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-04-07 16:06:18 -0400
commitf4baa925b0b5590bc8b12ba5f32e0218384c8efc (patch)
tree6c8f0eceaeaabc807e8cfd17e13bba86b8981970 /BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
parent7692fa077a84972231948354d3f0de99f27a9ad7 (diff)
Add simple toggle values
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
index cf60ed6..d92d564 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
@@ -42,6 +42,28 @@ public interface IList<ContainedType> extends Iterable<ContainedType> {
}
/**
+ * Add all of the elements in the provided array to this list.
+ *
+ * @param items
+ * The array of items to add.
+ *
+ * @return True if every item was successfully added to the list, false
+ * otherwise.
+ */
+ @SuppressWarnings("unchecked")
+ default boolean addAll(ContainedType... items) {
+ boolean succ = true;
+
+ for(ContainedType item : items) {
+ boolean addSucc = add(item);
+
+ succ = succ ? addSucc : false;
+ }
+
+ return succ;
+ }
+
+ /**
* Check if all of the elements of this list match the specified
* predicate.
*
@@ -238,6 +260,19 @@ public interface IList<ContainedType> extends Iterable<ContainedType> {
void prepend(ContainedType item);
/**
+ * Prepend an array of items to the list.
+ *
+ * @param items
+ * The items to prepend to the list.
+ */
+ @SuppressWarnings("unchecked")
+ default void prependAll(ContainedType... items) {
+ for(ContainedType item : items) {
+ prepend(item);
+ }
+ }
+
+ /**
* Select a random item from the list, using a default random number
* generator
*