From f133f377eb5bf86a26f9dae6f6cea445419e5786 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Tue, 17 Nov 2020 20:31:41 -0500 Subject: Reorder the methods in IMap again --- src/main/java/bjc/funcdata/IMap.java | 71 ++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'src/main/java/bjc') diff --git a/src/main/java/bjc/funcdata/IMap.java b/src/main/java/bjc/funcdata/IMap.java index 0879bca..4eaa9c0 100644 --- a/src/main/java/bjc/funcdata/IMap.java +++ b/src/main/java/bjc/funcdata/IMap.java @@ -121,11 +121,47 @@ public interface IMap extends IFreezable { return keyList().getSize(); } + /** + * Remove the value bound to the key. + * + * @param key + * 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. + */ + ValueType remove(KeyType key); + + /** + * Get a list of all the keys in this map. + * + * @return A list of all the keys in this map. + */ + IList keyList(); + + /** + * Get a list of the values in this map. + * + * @return A list of values in this map. + */ + default IList valueList() { + final IList returns = new FunctionalList<>(); + + for (final KeyType key : keyList()) { + returns.add(get(key)); + } + + return returns; + } + /* * @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. * @@ -166,41 +202,6 @@ public interface IMap extends IFreezable { default IMap extend(IMap backer) { return new ExtendedMap<>(this, backer); }; - - /** - * Remove the value bound to the key. - * - * @param key - * 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. - */ - ValueType remove(KeyType key); - - /** - * Get a list of all the keys in this map. - * - * @return A list of all the keys in this map. - */ - IList keyList(); - - /** - * Get a list of the values in this map. - * - * @return A list of values in this map. - */ - default IList valueList() { - final IList returns = new FunctionalList<>(); - - for (final KeyType key : keyList()) { - returns.add(get(key)); - } - - return returns; - } /** * Static method to create a basic instance of IMap. -- cgit v1.2.3