summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java120
1 files changed, 60 insertions, 60 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
index 0c96a9f..8a54246 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
@@ -18,21 +18,45 @@ import java.util.function.Function;
public interface IFunctionalMap<KeyType, ValueType> {
/**
- * Add an entry to the map
+ * Check if this map contains the specified key
*
* @param key
- * The key to put the value under
- * @param val
- * The value to add
- * @return The previous value of the key in the map, or null if the key
- * wasn't in the map. However, note that it may also return
- * null if the key was set to null.
+ * The key to check
+ * @return Whether or not the map contains the key
+ */
+ boolean containsKey(KeyType key);
+
+ /**
+ * Extends this map, creating a new map that will delegate queries to
+ * the map, but store any added values itself
*
- * @throws UnsupportedOperationException
- * if the map implementation doesn't support modifying the
- * map
+ * @return An extended map
*/
- ValueType put(KeyType key, ValueType val);
+ IFunctionalMap<KeyType, ValueType> extend();
+
+ /**
+ * Execute an action for each entry in the map
+ *
+ * @param action
+ * the action to execute for each entry in the map
+ */
+ void forEach(BiConsumer<KeyType, ValueType> action);
+
+ /**
+ * Perform an action for each key in the map
+ *
+ * @param action
+ * The action to perform on each key in the map
+ */
+ void forEachKey(Consumer<KeyType> action);
+
+ /**
+ * Perform an action for each value in the map
+ *
+ * @param action
+ * The action to perform on each value in the map
+ */
+ void forEachValue(Consumer<ValueType> action);
/**
* Get the value assigned to the given key
@@ -46,6 +70,20 @@ public interface IFunctionalMap<KeyType, ValueType> {
ValueType get(KeyType key);
/**
+ * Get the number of entries in this map
+ *
+ * @return The number of entries in this map
+ */
+ int getSize();
+
+ /**
+ * Get a list of all the keys in this map
+ *
+ * @return A list of all the keys in this map
+ */
+ IFunctionalList<KeyType> keyList();
+
+ /**
* Transform the values returned by this map.
*
* NOTE: This transform is applied once for each lookup of a value, so
@@ -62,28 +100,21 @@ public interface IFunctionalMap<KeyType, ValueType> {
Function<ValueType, V2> transformer);
/**
- * Check if this map contains the specified key
+ * Add an entry to the map
*
* @param key
- * The key to check
- * @return Whether or not the map contains the key
- */
- boolean containsKey(KeyType key);
-
- /**
- * Get a list of all the keys in this map
- *
- * @return A list of all the keys in this map
- */
- IFunctionalList<KeyType> keyList();
-
- /**
- * Execute an action for each entry in the map
+ * The key to put the value under
+ * @param val
+ * The value to add
+ * @return The previous value of the key in the map, or null if the key
+ * wasn't in the map. However, note that it may also return
+ * null if the key was set to null.
*
- * @param action
- * the action to execute for each entry in the map
+ * @throws UnsupportedOperationException
+ * if the map implementation doesn't support modifying the
+ * map
*/
- void forEach(BiConsumer<KeyType, ValueType> action);
+ ValueType put(KeyType key, ValueType val);
/**
* Remove the value bound to the key
@@ -98,40 +129,9 @@ public interface IFunctionalMap<KeyType, ValueType> {
ValueType remove(KeyType key);
/**
- * Get the number of entries in this map
- *
- * @return The number of entries in this map
- */
- int getSize();
-
- /**
- * Perform an action for each key in the map
- *
- * @param action
- * The action to perform on each key in the map
- */
- void forEachKey(Consumer<KeyType> action);
-
- /**
- * Perform an action for each value in the map
- *
- * @param action
- * The action to perform on each value in the map
- */
- void forEachValue(Consumer<ValueType> action);
-
- /**
* Get a list of the values in this map
*
* @return A list of values in this map
*/
IFunctionalList<ValueType> valueList();
-
- /**
- * Extends this map, creating a new map that will delegate queries to
- * the map, but store any added values itself
- *
- * @return An extended map
- */
- IFunctionalMap<KeyType, ValueType> extend();
} \ No newline at end of file