diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-11 22:49:16 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-11 22:49:16 -0300 |
| commit | 8923edffdb36b790014ff47301e53f7ede93ea0d (patch) | |
| tree | e1cff9168eb79110a8832249d208f2978f549a04 /base/src/main/java/bjc/utils/funcdata/IMap.java | |
| parent | 946cab444bc301d8a7c756a1bab039558288de89 (diff) | |
Cleanup more
Diffstat (limited to 'base/src/main/java/bjc/utils/funcdata/IMap.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcdata/IMap.java | 82 |
1 files changed, 47 insertions, 35 deletions
diff --git a/base/src/main/java/bjc/utils/funcdata/IMap.java b/base/src/main/java/bjc/utils/funcdata/IMap.java index 0ee7375..0262c13 100644 --- a/base/src/main/java/bjc/utils/funcdata/IMap.java +++ b/base/src/main/java/bjc/utils/funcdata/IMap.java @@ -10,17 +10,17 @@ import java.util.function.Function; * @author ben * * @param <KeyType> - * The type of this map's keys. + * The type of this map's keys. * * @param <ValueType> - * The type of this map's values. + * The type of this map's values. */ public interface IMap<KeyType, ValueType> { /** * Execute an action for each entry in the map. * * @param action - * the action to execute for each entry in the map. + * The action to execute for each entry in the map. */ void forEach(BiConsumer<KeyType, ValueType> action); @@ -28,7 +28,7 @@ public interface IMap<KeyType, ValueType> { * Perform an action for each key in the map. * * @param action - * The action to perform on each key in the map. + * The action to perform on each key in the map. */ default void forEachKey(final Consumer<KeyType> action) { forEach((key, val) -> action.accept(key)); @@ -38,7 +38,7 @@ public interface IMap<KeyType, ValueType> { * Perform an action for each value in the map. * * @param action - * The action to perform on each value in the map. + * The action to perform on each value in the map. */ default void forEachValue(final Consumer<ValueType> action) { forEach((key, val) -> action.accept(val)); @@ -48,9 +48,10 @@ public interface IMap<KeyType, ValueType> { * Check if this map contains the specified key. * * @param key - * The key to check. + * The key to check. * - * @return Whether or not the map contains the key. + * @return + * Whether or not the map contains the key. */ boolean containsKey(KeyType key); @@ -58,9 +59,10 @@ public interface IMap<KeyType, ValueType> { * Get the value assigned to the given key. * * @param key - * The key to look for a value under. + * The key to look for a value under. * - * @return The value of the key. + * @return + * The value of the key. */ ValueType get(KeyType key); @@ -69,13 +71,14 @@ public interface IMap<KeyType, ValueType> { * doesn't exist. * * @param key - * The key to attempt to retrieve. + * The key to attempt to retrieve. * * @param defaultValue - * The value to return if the key doesn't exist. + * The value to return if the key doesn't exist. * - * @return The value associated with the key, or the default value if - * the key doesn't exist. + * @return + * The value associated with the key, or the default value if the + * key doesn't exist. */ default ValueType getOrDefault(final KeyType key, final ValueType defaultValue) { try { @@ -93,24 +96,22 @@ public interface IMap<KeyType, ValueType> { * Add an entry to the map. * * @param key - * The key to put the value under. + * The key to put the value under. * * @param val - * The value to add. + * 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. + * @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. * * @throws UnsupportedOperationException - * if the map implementation doesn't support modifying - * the map + * If the map implementation doesn't support modifying the map. */ ValueType put(KeyType key, ValueType val); - /** - * Delete all the values in the map. - */ + /** Delete all the values in the map. */ default void clear() { keyList().forEach(key -> remove(key)); } @@ -118,12 +119,18 @@ public interface IMap<KeyType, ValueType> { /** * Get the number of entries in this map. * - * @return The number of entries in this map. + * @return + * The number of entries in this map. */ default int size() { return keyList().getSize(); } + /* @NOTE + * Do we want this to be the semantics for transform, or do we want + * to go to semantics using something like Isomorphism, or doing a + * one-time bulk conversion of the values? + */ /** * Transform the values returned by this map. * @@ -132,12 +139,13 @@ public interface IMap<KeyType, ValueType> { * likely not work as expected. * * @param <V2> - * The new type of returned values. + * The new type of returned values. * * @param transformer - * The function to use to transform values. + * The function to use to transform values. * - * @return The map where each value will be transformed after lookup. + * @return + * The map where each value will be transformed after lookup. */ default <V2> IMap<KeyType, V2> transform(final Function<ValueType, V2> transformer) { return new TransformedValueMap<>(this, transformer); @@ -147,7 +155,8 @@ public interface IMap<KeyType, ValueType> { * Extends this map, creating a new map that will delegate queries to * the map, but store any added values itself. * - * @return An extended map. + * @return + * An extended map. */ IMap<KeyType, ValueType> extend(); @@ -155,26 +164,29 @@ public interface IMap<KeyType, ValueType> { * Remove the value bound to the key. * * @param key - * The key to remove from the map. + * The key to remove from the map. * - * @return The previous value for the key in the map, or null if the key - * wasn't in the class. NOTE: Just because you received null, - * doesn't mean the map wasn't changed. It may mean that someone - * put a null value for that key into the map. + * @return + * The previous value for the key in the map, or null if the key + * wasn't in the class. NOTE: Just because you received null, + * doesn't mean the map wasn't changed. It may mean that someone + * put a null value for that key into the map. */ ValueType remove(KeyType key); /** * Get a list of all the keys in this map. * - * @return A list of all the keys in this map. + * @return + * A list of all the keys in this map. */ IList<KeyType> keyList(); /** * Get a list of the values in this map. * - * @return A list of values in this map. + * @return + * A list of values in this map. */ default IList<ValueType> valueList() { final IList<ValueType> returns = new FunctionalList<>(); |
