Commit 1416f773 authored by James C Bowden's avatar James C Bowden
Browse files

fix getCompletions ideque --> icollection

parent c6ad9364
No related merge requests found
Pipeline #62714 failed with stage
in 0 seconds
Showing with 13 additions and 2 deletions
+13 -2
...@@ -14,6 +14,16 @@ public interface ICollection<E> extends Iterable<E> { ...@@ -14,6 +14,16 @@ public interface ICollection<E> extends Iterable<E> {
*/ */
public void add(E e); public void add(E e);
/**
* Adds a collection of elements to this collection.
* @param c Collection of elements to add
*/
default public void addAll(ICollection<E> c) {
for (E e : c) {
this.add(e);
}
}
/** /**
* Removes all elements from the collection. * Removes all elements from the collection.
*/ */
......
...@@ -13,7 +13,7 @@ public interface ITrieMap<A, K extends Iterable<A>, V> extends IDictionary<K, V> ...@@ -13,7 +13,7 @@ public interface ITrieMap<A, K extends Iterable<A>, V> extends IDictionary<K, V>
* @param prefix the prefix to search for in the trie * @param prefix the prefix to search for in the trie
* @return the values corresponding to the keys starting with the given prefix * @return the values corresponding to the keys starting with the given prefix
*/ */
public IDeque<V> getCompletions(K prefix); public ICollection<V> getCompletions(K prefix);
/** /**
* Removes all elements from the trie. * Removes all elements from the trie.
......
...@@ -3,6 +3,7 @@ package edu.caltech.cs2.project07; ...@@ -3,6 +3,7 @@ package edu.caltech.cs2.project07;
import edu.caltech.cs2.datastructures.LinkedDeque; import edu.caltech.cs2.datastructures.LinkedDeque;
import edu.caltech.cs2.datastructures.Location; import edu.caltech.cs2.datastructures.Location;
import edu.caltech.cs2.datastructures.TrieMap; import edu.caltech.cs2.datastructures.TrieMap;
import edu.caltech.cs2.interfaces.ICollection;
import edu.caltech.cs2.interfaces.IDeque; import edu.caltech.cs2.interfaces.IDeque;
import edu.caltech.cs2.interfaces.ISet; import edu.caltech.cs2.interfaces.ISet;
import edu.caltech.cs2.interfaces.ITrieMap; import edu.caltech.cs2.interfaces.ITrieMap;
...@@ -93,7 +94,7 @@ public class MapsAutoCompleter { ...@@ -93,7 +94,7 @@ public class MapsAutoCompleter {
String[] keyPath = term.strip().toLowerCase().split("\\s"); String[] keyPath = term.strip().toLowerCase().split("\\s");
IDeque<String> kpIterable = listFromArray(keyPath); IDeque<String> kpIterable = listFromArray(keyPath);
IDeque<IDeque<Location>> options = locs.getCompletions(kpIterable); ICollection<IDeque<Location>> options = locs.getCompletions(kpIterable);
options.addAll(locs.getCompletions(charArrToStringIterable(term.toLowerCase().toCharArray()))); options.addAll(locs.getCompletions(charArrToStringIterable(term.toLowerCase().toCharArray())));
Set<Long> opts = new HashSet<>(); Set<Long> opts = new HashSet<>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment