Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs2-22wi
project06
Commits
7bbf9131
Commit
7bbf9131
authored
3 years ago
by
James C Bowden
Browse files
Options
Download
Email Patches
Plain Diff
getCompletions ideque --> icollection (untested)
parent
565e93f6
master
No related merge requests found
Pipeline
#62721
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/edu/caltech/cs2/interfaces/ITrieMap.java
+1
-1
src/edu/caltech/cs2/interfaces/ITrieMap.java
src/wordcorrector/AutoCompleteTrie.java
+2
-1
src/wordcorrector/AutoCompleteTrie.java
with
3 additions
and
2 deletions
+3
-2
src/edu/caltech/cs2/interfaces/ITrieMap.java
View file @
7bbf9131
...
...
@@ -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
* @return the values corresponding to the keys starting with the given prefix
*/
public
I
Deque
<
V
>
getCompletions
(
K
prefix
);
public
I
Collection
<
V
>
getCompletions
(
K
prefix
);
/**
* Removes all elements from the trie.
...
...
This diff is collapsed.
Click to expand it.
src/wordcorrector/AutoCompleteTrie.java
View file @
7bbf9131
...
...
@@ -3,6 +3,7 @@ package wordcorrector;
import
edu.caltech.cs2.datastructures.IterableString
;
import
edu.caltech.cs2.datastructures.LinkedDeque
;
import
edu.caltech.cs2.datastructures.TrieMap
;
import
edu.caltech.cs2.interfaces.ICollection
;
import
edu.caltech.cs2.interfaces.IDeque
;
import
java.io.File
;
...
...
@@ -45,7 +46,7 @@ public class AutoCompleteTrie extends TrieMap<Character, IterableString, AutoCom
* Retrieves keys that have the given key as a prefix
*/
public
IDeque
<
IterableString
>
autocomplete
(
String
keyString
)
{
I
Deque
<
Word
>
completions
=
this
.
getCompletions
(
new
IterableString
(
keyString
));
I
Collection
<
Word
>
completions
=
this
.
getCompletions
(
new
IterableString
(
keyString
));
IDeque
<
IterableString
>
suggestions
=
new
LinkedDeque
<>();
for
(
Word
completion
:
completions
)
{
suggestions
.
add
(
new
IterableString
(
completion
.
word
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help