summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/bjc/data/Multimap.java16
-rw-r--r--src/main/java/bjc/esodata/.AbbrevTree.java.un~bin0 -> 33807 bytes
-rw-r--r--src/main/java/bjc/esodata/AbbrevTree.java276
-rw-r--r--src/main/java/bjc/esodata/AbbrevTree.java~75
-rw-r--r--src/main/java/bjc/esodata/Multimap.java44
-rw-r--r--src/main/java/bjc/esodata/ThresholdSet.java74
-rw-r--r--src/main/java/module-info.java8
-rw-r--r--src/test/java/bjc/test/TestUtils.java (renamed from src/test/java/bjc/TestUtils.java)2
-rw-r--r--src/test/java/bjc/test/data/ArrayIteratorTest.java (renamed from src/test/java/bjc/data/ArrayIteratorTest.java)4
-rw-r--r--src/test/java/bjc/test/data/BooleanToggleTest.java (renamed from src/test/java/bjc/data/BooleanToggleTest.java)4
-rw-r--r--src/test/java/bjc/test/data/CircularIteratorTest.java (renamed from src/test/java/bjc/data/CircularIteratorTest.java)6
-rw-r--r--src/test/java/bjc/test/data/EitherTest.java (renamed from src/test/java/bjc/data/EitherTest.java)5
-rw-r--r--src/test/java/bjc/test/data/QueuedIteratorTest.java (renamed from src/test/java/bjc/data/QueuedIteratorTest.java)6
-rw-r--r--src/test/java/bjc/test/esodata/AbbrevTreeTest.java46
-rw-r--r--src/test/java/bjc/test/esodata/MinMaxListTest.java (renamed from src/test/java/bjc/esodata/MinMaxListTest.java)4
-rw-r--r--src/test/java/bjc/test/esodata/NestListTest.java (renamed from src/test/java/bjc/esodata/NestListTest.java)3
-rw-r--r--src/test/java/bjc/test/esodata/StackTest.java (renamed from src/test/java/bjc/esodata/StackTest.java)7
-rw-r--r--src/test/java/bjc/test/esodata/ThresholdSetTest.java (renamed from src/test/java/bjc/esodata/ThresholdSetTest.java)16
-rw-r--r--src/test/java/bjc/test/funcdata/TestMapCreation.java (renamed from src/test/java/bjc/funcdata/TestMapCreation.java)4
-rw-r--r--src/test/java/bjc/test/funcdata/TestMapOperations.java (renamed from src/test/java/bjc/funcdata/TestMapOperations.java)4
-rw-r--r--src/test/java/bjc/test/functypes/IDTest.java (renamed from src/test/java/bjc/functypes/IDTest.java)4
21 files changed, 537 insertions, 71 deletions
diff --git a/src/main/java/bjc/data/Multimap.java b/src/main/java/bjc/data/Multimap.java
deleted file mode 100644
index 0e858b7..0000000
--- a/src/main/java/bjc/data/Multimap.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package bjc.data;
-
-/**
- * A map with support for multiple values per key.
- *
- * @param <KeyType>
- * The type of the keys for the map.
- * @param <ValueType>
- * The type of the values for the map.
- *
- * @author Ben Culkin
- */
-public class Multimap<KeyType, ValueType> {
- // TODO either implement this, or find if there is an implementation I've
- // written elsewhere
-}
diff --git a/src/main/java/bjc/esodata/.AbbrevTree.java.un~ b/src/main/java/bjc/esodata/.AbbrevTree.java.un~
new file mode 100644
index 0000000..7c8a369
--- /dev/null
+++ b/src/main/java/bjc/esodata/.AbbrevTree.java.un~
Binary files differ
diff --git a/src/main/java/bjc/esodata/AbbrevTree.java b/src/main/java/bjc/esodata/AbbrevTree.java
new file mode 100644
index 0000000..35c44f0
--- /dev/null
+++ b/src/main/java/bjc/esodata/AbbrevTree.java
@@ -0,0 +1,276 @@
+package bjc.esodata;
+
+import java.util.*;
+
+import bjc.data.Pair;
+import bjc.data.TransformIterator;
+import bjc.funcdata.FunctionalList;
+import bjc.funcdata.ListEx;
+
+/**
+ * A labeled tree, where you can reference sub-nodes by their label as long as
+ * the reference is unambiguous.
+ *
+ * Inspired by the way that you can reference COBOL members by their name, as
+ * long as it is unambiguous. If it is ambiguous, you can instead use parent
+ * nodes to disambiguate.
+ *
+ * Additional note: The base iterator will give you all of the child nodes, but
+ * in no defined order.
+ *
+ * @param <Label> The label on each node
+ * @param <Contained> The type of data contained in the nodes.
+ */
+public class AbbrevTree<Label, Contained> implements Iterable<Pair<Label, Contained>> {
+ private Multimap<Label, AbbrevTree<Label, Contained>> labelledNodes;
+
+ private Map<Label, AbbrevTree<Label, Contained>> children;
+ private AbbrevTree<Label, Contained> parent;
+
+ private Contained data;
+ private Label label;
+
+ /**
+ * Create a new empty root AbbrevTree.
+ */
+ public AbbrevTree() {
+ labelledNodes = new Multimap<>();
+ children = new HashMap<>();
+ }
+
+ /**
+ * Create a new occupied root AbbrevTree
+ *
+ * @param label The label for this tree
+ * @param data The data for this tree
+ */
+ public AbbrevTree(Label label, Contained data) {
+ this();
+
+ this.label = label;
+ this.data = data;
+ }
+
+ /**
+ * Create a new empty child AbbrevTree.
+ *
+ * @param parent The parent of this node
+ */
+ public AbbrevTree(AbbrevTree<Label, Contained> parent) {
+ labelledNodes = new Multimap<>();
+ children = new HashMap<>();
+
+ this.parent = parent;
+ }
+
+ /**
+ * Create a new occupied child AbbrevTree
+ *
+ * @param parent The parent of this node
+ * @param label The label for this tree
+ * @param data The data for this tree
+ */
+ public AbbrevTree(AbbrevTree<Label, Contained> parent, Label label, Contained data) {
+ this();
+
+ this.parent = parent;
+ this.label = label;
+ this.data = data;
+
+ addFromChild(label, this);
+ }
+
+ private void addFromChild(Label lbl, AbbrevTree<Label, Contained> node) {
+ labelledNodes.add(lbl, node);
+
+ if (parent != null)
+ parent.addFromChild(lbl, node);
+ }
+
+ /**
+ * Get the data contained in this node.
+ *
+ * @return The contained data.
+ */
+ public Contained getData() {
+ return data;
+ }
+
+ /**
+ * Set the data contained in this node.
+ *
+ * @param data The new data.
+ */
+ public void setData(Contained data) {
+ this.data = data;
+ }
+
+ /**
+ * Get the label for this node.
+ *
+ * @return The label for this node.
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /*
+ * Unsupported for now. This requires some additional scaffolding.
+ *
+ * Set the label for this node.
+ *
+ * @param label The new label for this node.
+ */
+ // public void setLabel(Label label) {
+ // this.label = label;
+ // }
+
+ /**
+ * Add a child to this node
+ *
+ * @param key The label for the new node
+ * @param dat The data for the new node.
+ *
+ * @return The new node
+ */
+ public AbbrevTree<Label, Contained> add(Label key, Contained dat) {
+ AbbrevTree<Label, Contained> node = new AbbrevTree<>(this, key, dat);
+
+ children.put(key, node);
+
+ return node;
+ }
+
+ /**
+ * Remove a direct child from this node.
+ *
+ * @param key The label for this child.
+ *
+ * @return The removed child.
+ */
+ public Optional<AbbrevTree<Label, Contained>> removeChild(Label key) {
+ Optional<AbbrevTree<Label, Contained>> res = Optional.ofNullable(children.remove(key));
+
+ res.ifPresent((node) -> {
+ node.parent = null;
+ node.labelledNodes.iterator().forEachRemaining((par) -> {
+ labelledNodes.remove(par.getLeft(), par.getRight());
+
+ parent.labelledNodes.remove(par.getLeft(), par.getRight());
+ });
+ });
+
+ return res;
+ }
+
+ /**
+ * Retrieve a number of subnodes from this tree which correspond to the given
+ * keys.
+ *
+ * Note that the keys are passed in reverse order. Essentially, the first
+ * argument is the actual key, the remainder are just disambiguators
+ *
+ * @param keys The keys to look up.
+ *
+ * @return All of the nodes which match the given key pattern.
+ */
+ public Set<AbbrevTree<Label, Contained>> nodes(@SuppressWarnings("unchecked") Label... keys) {
+ // Need this; Java can't deduce the proper type for reduceAux otherwise
+ Set<AbbrevTree<Label, Contained>> nodes = new HashSet<>();
+
+ ListEx<Label> keyList = new FunctionalList<>(keys);
+
+ // COBOL keylists are in reverse order
+ keyList.reverse();
+
+ Label last = keyList.popLast();
+
+ List<AbbrevTree<Label, Contained>> focusList = List.of(this);
+ for (Label key : keyList) {
+ List<AbbrevTree<Label, Contained>> nextFocus = new ArrayList<>();
+
+ for (AbbrevTree<Label, Contained> focus : focusList) {
+ Set<AbbrevTree<Label, Contained>> focusSet = focus.labelledNodes.get(key);
+ nextFocus.addAll(focusSet);
+ }
+
+ focusList = nextFocus;
+ }
+
+ focusList.forEach((focus) -> {
+ nodes.addAll(focus.labelledNodes.get(last));
+ });
+
+ if (label.equals(last))
+ nodes.add(this);
+
+ return nodes;
+ }
+
+ /**
+ * Retrieve all of the values which correspond to a given key.
+ *
+ *
+ * Note that the keys are passed in reverse order. Essentially, the first
+ * argument is the actual key, the remainder are just disambiguators
+ *
+ * @param keys The keys to look up
+ *
+ * @return All of the values which correspond to the key
+ */
+ public Set<Contained> values(@SuppressWarnings("unchecked") Label... keys) {
+ Set<Contained> res = new HashSet<>();
+
+ nodes(keys).forEach((node) -> res.add(node.data));
+
+ return res;
+ }
+
+ /**
+ * Returns the singular value identified by the given keypath.
+ *
+ * Note that unlike {@link AbbrevTree#nodes(Object...)} and
+ * {@link AbbrevTree#values(Object...)}, the keys to this method are passed in
+ * the proper order, not reverse.
+ *
+ * @param keys The keypath to look up.
+ *
+ * @return An optional containing the identified element if there is one;
+ * otherwise, empty.
+ */
+ public Optional<AbbrevTree<Label, Contained>> path(@SuppressWarnings("unchecked") Label... keys) {
+ Optional<AbbrevTree<Label, Contained>> focus = Optional.of(this);
+
+ for (Label key : keys) {
+ focus.map((node) -> {
+ return node.children.get(key);
+ });
+ }
+
+ return focus;
+ }
+
+ @Override
+ public Iterator<Pair<Label, Contained>> iterator() {
+ return new TransformIterator<>(labelledNodes.iterator(),
+ (node) -> node.mapRight(AbbrevTree<Label, Contained>::getData));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(children, data, label, parent);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AbbrevTree<?, ?> other = (AbbrevTree<?, ?>) obj;
+ return Objects.equals(children, other.children) && Objects.equals(data, other.data)
+ && Objects.equals(label, other.label);
+ }
+}
diff --git a/src/main/java/bjc/esodata/AbbrevTree.java~ b/src/main/java/bjc/esodata/AbbrevTree.java~
new file mode 100644
index 0000000..a391028
--- /dev/null
+++ b/src/main/java/bjc/esodata/AbbrevTree.java~
@@ -0,0 +1,75 @@
+package bjc.esodata;
+
+import java.util.*;
+
+/**
+ * A labeled tree, where you can reference sub-nodes by their label as long as the reference is unambiguous.
+ *
+ * Inspired by the way that you can reference COBOL members by their name, as long as it is unambiguous. If it is ambiguous, you can instead use parent nodes to disambiguate.
+ *
+ * @param <Contained> The type of data contained in the nodes.
+ */
+public class AbbrevTree<Contained> {
+ /** Represents a single node in an AbbrevTree */
+ public interface AbbrevNode<Contained> {
+ /** The label for the node. */
+ public String getLabel();
+ /** The data for the node. */
+ public Contained getData();
+ /**
+ * Add a child to this node.
+ *
+ * If a node already exists with the given label, it will be replaced.
+ *
+ * @param label The label for the child.
+ * @param contained The data contained in the child.
+ */
+ public void addChild(String label, String contained);
+ /**
+ * Get a child, starting the search from this node.
+ * @param labels The label(s) to search for. If the label is ambiguous, provide additional ones to make it unambiguous.
+ */
+ public AbbrevNode<Contained> getNode(String... labels);
+ }
+
+ public Contained get(String... labels) {
+ return null;
+ }
+}
+
+class AbbrevNode<Contained> {
+ private String label;
+ private Contained data;
+
+ private List<AbbrevNode<Contained>> children;
+ private AbbrevTree<Contained> container;
+
+ /**
+ * Create a new AbbrevNode with a label and contents.
+ * @param label The label for this node.
+ * @param data The data contained in the node.
+ * @param container The tree that contains the node.
+ */
+ public AbbrevNode(String label, Contained data, AbbrevTree<Contained> container) {
+ this(container);
+
+ this.label = label;
+ this.data = data;
+ }
+
+ /**
+ * Get the label for this node.
+ * @return The label for this node.
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Get the data for this node.
+ * @return The data for this node.
+ */
+ public Contained getData() {
+ return data;
+ }
+}
diff --git a/src/main/java/bjc/esodata/Multimap.java b/src/main/java/bjc/esodata/Multimap.java
index fae872e..e18ed49 100644
--- a/src/main/java/bjc/esodata/Multimap.java
+++ b/src/main/java/bjc/esodata/Multimap.java
@@ -1,6 +1,9 @@
package bjc.esodata;
import java.util.*;
+import java.util.Map.Entry;
+
+import bjc.data.Pair;
/**
* A map that has support for multiple values for a given key.
@@ -14,7 +17,7 @@ import java.util.*;
* @param <KeyType> The type of keys in the map.
* @param <ValueType> The type of values in the map.
*/
-public class Multimap<KeyType, ValueType> {
+public class Multimap<KeyType, ValueType> implements Iterable<Pair<KeyType, ValueType>> {
private Map<KeyType, ThresholdSet<ValueType>> backing;
/**
@@ -80,6 +83,17 @@ public class Multimap<KeyType, ValueType> {
}
/**
+ * Get the single value in the map, if there is one.
+ * @param key The key to look up
+ * @return An optional containing the key if it is there once, or empty if it is there either no or more than one times
+ */
+ public Optional<ValueType> getSingle(KeyType key) {
+ Set<ValueType> set = get(key);
+
+ if (set.size() == 1) return Optional.of(set.iterator().next());
+ return Optional.empty();
+ }
+ /**
* Check if there is at least one value mapped to the given key.
*
* @param key
@@ -108,4 +122,32 @@ public class Multimap<KeyType, ValueType> {
return backing.get(key).contains(value) > 0;
}
+
+ @Override
+ public Iterator<Pair<KeyType, ValueType>> iterator() {
+ return new Iterator<>() {
+ private Iterator<Entry<KeyType, ThresholdSet<ValueType>>> mapIter = backing.entrySet().iterator();
+ private KeyType currKey;
+ private Iterator<ValueType> setIter;
+
+ @Override
+ public boolean hasNext() {
+ while (setIter == null || !setIter.hasNext()) {
+ if (!mapIter.hasNext()) return false;
+ Entry<KeyType,ThresholdSet<ValueType>> entry = mapIter.next();
+
+ currKey = entry.getKey();
+ setIter = entry.getValue().setView().iterator();
+ }
+
+ return setIter.hasNext();
+ }
+
+ @Override
+ public Pair<KeyType, ValueType> next() {
+ if (setIter == null || !setIter.hasNext()) throw new NoSuchElementException();
+ return Pair.pair(currKey, setIter.next()) ;
+ }
+ };
+ }
}
diff --git a/src/main/java/bjc/esodata/ThresholdSet.java b/src/main/java/bjc/esodata/ThresholdSet.java
index 9b8560b..c13bad3 100644
--- a/src/main/java/bjc/esodata/ThresholdSet.java
+++ b/src/main/java/bjc/esodata/ThresholdSet.java
@@ -2,6 +2,10 @@ package bjc.esodata;
import java.util.*;
+import bjc.data.Pair;
+import bjc.data.SimplePair;
+import bjc.data.TransformIterator;
+
/**
* Represents a counted set, that overflows to a map.
*
@@ -17,12 +21,11 @@ import java.util.*;
* The iterator that this type gives by default is an iterator over all of the
* values in the set, not including any of those in the map.
*
- * @param <KeyType>
- * The value being counted.
+ * @param <KeyType> The value being counted.
*
* @author Ben Culkin
*/
-public class ThresholdSet<KeyType> {
+public class ThresholdSet<KeyType> implements Iterable<Pair<KeyType, Integer>> {
// View of this class as a java.util.Set
private class SetView extends AbstractSet<KeyType> {
/*
@@ -37,7 +40,8 @@ public class ThresholdSet<KeyType> {
int ret = ThresholdSet.this.add(key);
// No change to set contents
- if (ret > 2) return false;
+ if (ret > 2)
+ return false;
return true;
}
@@ -51,7 +55,8 @@ public class ThresholdSet<KeyType> {
int ret = ThresholdSet.this.remove(k);
// We removed the element.
- if (ret == 0) return true;
+ if (ret == 0)
+ return true;
return false;
}
@@ -65,7 +70,8 @@ public class ThresholdSet<KeyType> {
int ret = ThresholdSet.this.contains(k);
// The object is set-visible
- if (ret == 1) return true;
+ if (ret == 1)
+ return true;
return false;
}
@@ -101,15 +107,15 @@ public class ThresholdSet<KeyType> {
/**
* Add multiple keys at once to the map.
*
- * @param keys
- * The keys to add.
+ * @param keys The keys to add.
*
* @return An array containing the results of adding the keys.
*/
public int[] addKeys(@SuppressWarnings("unchecked") KeyType... keys) {
int[] ret = new int[keys.length];
- for (int i = 0; i < keys.length; i++) ret[i] = add(keys[i]);
+ for (int i = 0; i < keys.length; i++)
+ ret[i] = add(keys[i]);
return ret;
}
@@ -117,11 +123,10 @@ public class ThresholdSet<KeyType> {
/**
* Add a key to the collection.
*
- * @param key
- * The key to add to the collection.
+ * @param key The key to add to the collection.
*
* @return The number of times that key now exists in the collection. Should
- * always be &lt; 0.
+ * always be &gt; 0.
*/
public int add(KeyType key) {
if (keySet.contains(key)) {
@@ -149,15 +154,15 @@ public class ThresholdSet<KeyType> {
/**
* Remove a bunch of keys from the collection.
*
- * @param keys
- * The keys to remove from the collection.
+ * @param keys The keys to remove from the collection.
*
* @return The results from removing the keys.
*/
public int[] removeKeys(@SuppressWarnings("unchecked") KeyType... keys) {
int[] ret = new int[keys.length];
- for (int i = 0; i < keys.length; i++) ret[i] = remove(keys[i]);
+ for (int i = 0; i < keys.length; i++)
+ ret[i] = remove(keys[i]);
return ret;
}
@@ -165,8 +170,7 @@ public class ThresholdSet<KeyType> {
/**
* Remove a key from the collection.
*
- * @param key
- * The key to remove from the collection.
+ * @param key The key to remove from the collection.
*
* @return The number of times that key now exists in the collection. Returns -1
* if that key wasn't in the collection beforehand.
@@ -188,11 +192,11 @@ public class ThresholdSet<KeyType> {
keySet.add(key);
return 1;
- } else {
- keyMap.put(key, cnt);
-
- return cnt;
}
+
+ keyMap.put(key, cnt);
+
+ return cnt;
} else {
// We don't know about that key
return -1;
@@ -202,15 +206,15 @@ public class ThresholdSet<KeyType> {
/**
* Get the number of times the set contains a set of given keys.
*
- * @param keys
- * The keys to look for.
+ * @param keys The keys to look for.
*
* @return The containment counts for each key.
*/
public int[] containsKeys(@SuppressWarnings("unchecked") KeyType... keys) {
int[] ret = new int[keys.length];
- for (int i = 0; i < keys.length; i++) ret[i] = contains(keys[i]);
+ for (int i = 0; i < keys.length; i++)
+ ret[i] = contains(keys[i]);
return ret;
}
@@ -218,15 +222,17 @@ public class ThresholdSet<KeyType> {
/**
* Get the number of times the set contains a given key.
*
- * @param key
- * The key to look for.
+ * @param key The key to look for.
*
* @return The number of times the key occurs; -1 if it doesn't occur.
*/
public int contains(KeyType key) {
- if (keySet.contains(key)) return 1;
- if (!keyMap.containsKey(key)) return -1;
- else return keyMap.get(key);
+ if (keySet.contains(key))
+ return 1;
+ if (!keyMap.containsKey(key))
+ return -1;
+
+ return keyMap.get(key);
}
/**
@@ -252,12 +258,18 @@ public class ThresholdSet<KeyType> {
return new SetView();
}
+ @Override
+ public Iterator<Pair<KeyType, Integer>> iterator() {
+ return new TransformIterator<>(keyMap.entrySet().iterator(),
+ (entry) -> new SimplePair<>(entry.getKey(), entry.getValue()));
+ }
+
/**
* Static threshold set constructor.
+ *
* @param <KType> The type of keys for the threshold set.
*
- * @param keys
- * The initial keys to add to the threshold set.
+ * @param keys The initial keys to add to the threshold set.
* @return A threshold set with the given keys.
*/
@SafeVarargs
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 0000000..84d1b2f
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,8 @@
+module esodata {
+ exports bjc.data;
+ exports bjc.esodata;
+ exports bjc.functypes;
+ exports bjc.funcdata.bst;
+ exports bjc.funcdata.theory;
+ exports bjc.funcdata;
+} \ No newline at end of file
diff --git a/src/test/java/bjc/TestUtils.java b/src/test/java/bjc/test/TestUtils.java
index 312ebaf..d79157d 100644
--- a/src/test/java/bjc/TestUtils.java
+++ b/src/test/java/bjc/test/TestUtils.java
@@ -1,4 +1,4 @@
-package bjc;
+package bjc.test;
import java.util.*;
diff --git a/src/test/java/bjc/data/ArrayIteratorTest.java b/src/test/java/bjc/test/data/ArrayIteratorTest.java
index 223eea2..c446f53 100644
--- a/src/test/java/bjc/data/ArrayIteratorTest.java
+++ b/src/test/java/bjc/test/data/ArrayIteratorTest.java
@@ -1,12 +1,14 @@
/**
*
*/
-package bjc.data;
+package bjc.test.data;
import static org.junit.Assert.*;
import org.junit.*;
+import bjc.data.ArrayIterator;
+
/**
* Test ArrayIterator
* @author Ben Culkin
diff --git a/src/test/java/bjc/data/BooleanToggleTest.java b/src/test/java/bjc/test/data/BooleanToggleTest.java
index 0b0937f..7577340 100644
--- a/src/test/java/bjc/data/BooleanToggleTest.java
+++ b/src/test/java/bjc/test/data/BooleanToggleTest.java
@@ -1,9 +1,11 @@
-package bjc.data;
+package bjc.test.data;
import static org.junit.Assert.*;
import org.junit.Test;
+import bjc.data.BooleanToggle;
+
/**
* Test for boolean toggles.
*
diff --git a/src/test/java/bjc/data/CircularIteratorTest.java b/src/test/java/bjc/test/data/CircularIteratorTest.java
index 8091e1c..9dd7637 100644
--- a/src/test/java/bjc/data/CircularIteratorTest.java
+++ b/src/test/java/bjc/test/data/CircularIteratorTest.java
@@ -1,10 +1,12 @@
-package bjc.data;
+package bjc.test.data;
-import static bjc.TestUtils.*;
+import static bjc.test.TestUtils.*;
import java.util.*;
import org.junit.Test;
+import bjc.data.CircularIterator;
+
/**
* Test for circular iterators.,
*
diff --git a/src/test/java/bjc/data/EitherTest.java b/src/test/java/bjc/test/data/EitherTest.java
index ef2d12b..5e2613c 100644
--- a/src/test/java/bjc/data/EitherTest.java
+++ b/src/test/java/bjc/test/data/EitherTest.java
@@ -1,4 +1,4 @@
-package bjc.data;
+package bjc.test.data;
import static org.junit.Assert.*;
@@ -6,7 +6,8 @@ import java.util.*;
import org.junit.*;
-@SuppressWarnings("javadoc")
+import bjc.data.Either;
+
public class EitherTest
{
private Either<String, String> leftEither;
diff --git a/src/test/java/bjc/data/QueuedIteratorTest.java b/src/test/java/bjc/test/data/QueuedIteratorTest.java
index b880f97..a059e96 100644
--- a/src/test/java/bjc/data/QueuedIteratorTest.java
+++ b/src/test/java/bjc/test/data/QueuedIteratorTest.java
@@ -1,10 +1,12 @@
-package bjc.data;
+package bjc.test.data;
import static java.util.Arrays.asList;
import org.junit.Test;
-import static bjc.TestUtils.*;
+import bjc.data.QueuedIterator;
+
+import static bjc.test.TestUtils.*;
import static bjc.data.QueuedIterator.queued;
/**
diff --git a/src/test/java/bjc/test/esodata/AbbrevTreeTest.java b/src/test/java/bjc/test/esodata/AbbrevTreeTest.java
new file mode 100644
index 0000000..1332b63
--- /dev/null
+++ b/src/test/java/bjc/test/esodata/AbbrevTreeTest.java
@@ -0,0 +1,46 @@
+package bjc.test.esodata;
+
+import static org.junit.Assert.*;
+import static bjc.test.TestUtils.*;
+
+import org.junit.Test;
+
+import bjc.esodata.AbbrevTree;
+
+@SuppressWarnings("javadoc")
+public class AbbrevTreeTest {
+ private static class StringTree extends AbbrevTree<String, String> {
+ // Alias type
+ public StringTree(AbbrevTree<String, String> parent, String label, String data) {
+ super(parent, label, data);
+ }
+
+ public StringTree(String label, String data) {
+ super(label, data);
+ }
+ }
+
+ @Test
+ public void testGet() {
+ StringTree root = new StringTree("root", "a");
+
+ StringTree leaf1 = new StringTree(root, "leaf", "b1");
+ StringTree node1 = new StringTree(root, "node1", "b2");
+
+ StringTree node2 = new StringTree(node1, "node2", "c1");
+ StringTree leaf2 = new StringTree(node1, "leaf", "c2");
+
+ var list1 = root.nodes("node2");
+ assertEquals(1, list1.size());
+ assertIteratorSet(false, list1.iterator(), node2);
+
+ var list2 = root.nodes("leaf");
+ assertEquals(2, list2.size());
+ assertIteratorSet(false, list2.iterator(), leaf1, leaf2);
+
+ var list3 = root.nodes("leaf", "node1");
+ assertEquals(1, list3.size());
+ assertIteratorSet(false, list3.iterator(), leaf2);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/bjc/esodata/MinMaxListTest.java b/src/test/java/bjc/test/esodata/MinMaxListTest.java
index 08901f0..0337ef7 100644
--- a/src/test/java/bjc/esodata/MinMaxListTest.java
+++ b/src/test/java/bjc/test/esodata/MinMaxListTest.java
@@ -1,4 +1,4 @@
-package bjc.esodata;
+package bjc.test.esodata;
import static org.junit.Assert.*;
@@ -6,6 +6,8 @@ import java.util.*;
import org.junit.*;
+import bjc.esodata.MinMaxList;
+
@SuppressWarnings("javadoc")
public class MinMaxListTest {
private final static Comparator<Integer> intComparator = (lhs, rhs) -> lhs - rhs;;
diff --git a/src/test/java/bjc/esodata/NestListTest.java b/src/test/java/bjc/test/esodata/NestListTest.java
index ff3723e..15b2bab 100644
--- a/src/test/java/bjc/esodata/NestListTest.java
+++ b/src/test/java/bjc/test/esodata/NestListTest.java
@@ -1,4 +1,4 @@
-package bjc.esodata;
+package bjc.test.esodata;
import static org.junit.Assert.*;
@@ -7,6 +7,7 @@ import java.util.*;
import org.junit.*;
import bjc.*;
+import bjc.esodata.NestList;
@SuppressWarnings("javadoc")
public class NestListTest
diff --git a/src/test/java/bjc/esodata/StackTest.java b/src/test/java/bjc/test/esodata/StackTest.java
index b4b98cc..7f896a7 100644
--- a/src/test/java/bjc/esodata/StackTest.java
+++ b/src/test/java/bjc/test/esodata/StackTest.java
@@ -1,8 +1,11 @@
-package bjc.esodata;
+package bjc.test.esodata;
import org.junit.Test;
-import static bjc.TestUtils.*;
+import bjc.esodata.SimpleStack;
+import bjc.esodata.Stack;
+
+import static bjc.test.TestUtils.*;
import static org.junit.Assert.*;
diff --git a/src/test/java/bjc/esodata/ThresholdSetTest.java b/src/test/java/bjc/test/esodata/ThresholdSetTest.java
index c9403da..142a641 100644
--- a/src/test/java/bjc/esodata/ThresholdSetTest.java
+++ b/src/test/java/bjc/test/esodata/ThresholdSetTest.java
@@ -1,8 +1,10 @@
-package bjc.esodata;
+package bjc.test.esodata;
import org.junit.Test;
-import static bjc.TestUtils.*;
+import bjc.esodata.ThresholdSet;
+
+import static bjc.test.TestUtils.*;
import static bjc.esodata.ThresholdSet.*;
@@ -20,7 +22,7 @@ public class ThresholdSetTest {
ThresholdSet<String> thst = TS("a", "b");
assertIteratorSet(false, thst.setView().iterator(), "a", "b");
- assertEquals(thst.setSize(), 2);
+ assertEquals(thst.setView().size(), 2);
}
@Test
@@ -28,7 +30,7 @@ public class ThresholdSetTest {
ThresholdSet<String> thst = TS("a", "b", "a");
assertIteratorSet(false, thst.setView().iterator(), "b");
- assertEquals(thst.setSize(), 1);
+ assertEquals(thst.setView().size(), 1);
}
@Test
@@ -37,7 +39,7 @@ public class ThresholdSetTest {
thst.add("a");
assertIteratorSet(false, thst.setView().iterator(), "b");
- assertEquals(thst.setSize(), 1);
+ assertEquals(thst.setView().size(), 1);
}
@Test
@@ -57,12 +59,12 @@ public class ThresholdSetTest {
thst.remove("a");
assertIteratorSet(false, thst.setView().iterator(), "a", "b");
- assertEquals(2, thst.setSize());
+ assertEquals(2, thst.setView().size());
thst.remove("a");
assertIteratorSet(false, thst.setView().iterator(), "b");
- assertEquals(1, thst.setSize());
+ assertEquals(1, thst.setView().size());
}
@Test
diff --git a/src/test/java/bjc/funcdata/TestMapCreation.java b/src/test/java/bjc/test/funcdata/TestMapCreation.java
index eeea591..4a06aa0 100644
--- a/src/test/java/bjc/funcdata/TestMapCreation.java
+++ b/src/test/java/bjc/test/funcdata/TestMapCreation.java
@@ -1,9 +1,11 @@
-package bjc.funcdata;
+package bjc.test.funcdata;
import static org.junit.Assert.*;
import org.junit.*;
+import bjc.funcdata.MapEx;
+
@SuppressWarnings("javadoc")
public class TestMapCreation {
@Test
diff --git a/src/test/java/bjc/funcdata/TestMapOperations.java b/src/test/java/bjc/test/funcdata/TestMapOperations.java
index 7523d02..fa38a79 100644
--- a/src/test/java/bjc/funcdata/TestMapOperations.java
+++ b/src/test/java/bjc/test/funcdata/TestMapOperations.java
@@ -1,4 +1,4 @@
-package bjc.funcdata;
+package bjc.test.funcdata;
import static org.junit.Assert.*;
@@ -6,6 +6,8 @@ import java.util.*;
import org.junit.*;
+import bjc.funcdata.MapEx;
+
@SuppressWarnings("javadoc")
public class TestMapOperations {
private MapEx<String, String> map;
diff --git a/src/test/java/bjc/functypes/IDTest.java b/src/test/java/bjc/test/functypes/IDTest.java
index 69c6133..4e31644 100644
--- a/src/test/java/bjc/functypes/IDTest.java
+++ b/src/test/java/bjc/test/functypes/IDTest.java
@@ -1,4 +1,4 @@
-package bjc.functypes;
+package bjc.test.functypes;
import static org.junit.Assert.*;
@@ -6,6 +6,8 @@ import java.util.function.*;
import org.junit.*;
+import bjc.functypes.ID;
+
@SuppressWarnings("javadoc")
public class IDTest {