summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/esodata/ThresholdSet.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2019-07-27 23:10:16 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2019-07-27 23:10:16 -0400
commitfadc9d01f662ab001d9fdd0fd92c5f0c177557cd (patch)
tree0747e6746c3b7f33016bf8ed0324bd6972b09795 /src/main/java/bjc/esodata/ThresholdSet.java
parenta623c8fafaa103a902fbdb4936b2ee78463ae5ba (diff)
Reimplement AbbrevMap, and implement Multimap
This reimplements the old AbbrevMap structure as AbbrevMap2, and created a new Multimap structure as a apart of it. Multimap is exactly what it sounds like; a map that allows multiple values for a given key. The only real thing that is different about it, is that if you add a key-value pair multiple times, you'll have to remove it multiple times.
Diffstat (limited to 'src/main/java/bjc/esodata/ThresholdSet.java')
-rw-r--r--src/main/java/bjc/esodata/ThresholdSet.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/bjc/esodata/ThresholdSet.java b/src/main/java/bjc/esodata/ThresholdSet.java
index 245eb5f..cc7c0e1 100644
--- a/src/main/java/bjc/esodata/ThresholdSet.java
+++ b/src/main/java/bjc/esodata/ThresholdSet.java
@@ -2,6 +2,8 @@ package bjc.esodata;
import java.util.*;
+import bjc.data.*;
+
/**
* Represents a counted set, that overflows to a map.
*
@@ -80,7 +82,8 @@ public class ThresholdSet<KeyType> {
private Set<KeyType> keySet;
// @TODO :CountMap Ben Culkin 6/19/2019
- // Replace this with a CountSet or some equivalent concept, whenever that gets written
+ // Replace this with a CountSet or some equivalent concept, whenever that gets written, if that
+ // gets written
private Map<KeyType, Integer> keyMap;
/**
@@ -94,8 +97,9 @@ public class ThresholdSet<KeyType> {
/**
* Add multiple keys at once to the map.
*
- * @param keys
- * The keys to add.
+ * @param key
+ * The keys to add.
+ *
* @return An array containing the results of adding the keys.
*/
public int[] addKeys(KeyType... keys) {
@@ -112,7 +116,8 @@ public class ThresholdSet<KeyType> {
* Add a key to the collection.
*
* @param key
- * The key to add to the collection.
+ * The key to add to the collection.
+ *
* @return The number of times that key now exists in the collection. Should always be &lt; 0.
*/
public int add(KeyType key) {
@@ -227,6 +232,20 @@ public class ThresholdSet<KeyType> {
}
/**
+ * Get a set containing all of the values that are in this set at least once.
+ *
+ * @return A set containing every value that occurs at least once in this set.
+ */
+ public Set<KeyType> values() {
+ Set<KeyType> retSet = new HashSet<>();
+
+ retSet.addAll(keySet);
+ retSet.addAll(keyMap.keySet());
+
+ return retSet;
+ }
+
+ /**
* Get a view of this collection as a java.util.Set.
*
* @return A view of the collection as a set.