From e401fb037c555eb18db54708037a796523258c32 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 10 Jul 2019 17:10:51 -0400 Subject: General improvements to stack --- src/main/java/bjc/esodata/ThresholdSet.java | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/main/java/bjc/esodata/ThresholdSet.java') diff --git a/src/main/java/bjc/esodata/ThresholdSet.java b/src/main/java/bjc/esodata/ThresholdSet.java index bc1b517..245eb5f 100644 --- a/src/main/java/bjc/esodata/ThresholdSet.java +++ b/src/main/java/bjc/esodata/ThresholdSet.java @@ -57,7 +57,7 @@ public class ThresholdSet { // Will throw a ClassCastException if you give us something bad. KeyType k = (KeyType)o; - int ret = ThresholdSet.this.remove(k); + int ret = ThresholdSet.this.contains(k); // The object is set-visible if (ret == 1) return true; @@ -235,6 +235,32 @@ public class ThresholdSet { return new SetView(); } + /** + * Static threshold set constructor. + * + * @param keys + * The initial keys to add to the threshold set. + */ + public static ThresholdSet TS(KType... keys) { + ThresholdSet ts = new ThresholdSet<>(); + + ts.addKeys(keys); + + return ts; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + sb.append("Set: "); + sb.append(keySet); + sb.append("\nMap: "); + sb.append(keyMap); + + return sb.toString(); + } + // Implementation methods for setView int setSize() { -- cgit v1.2.3