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
project07
Commits
1416f773
Commit
1416f773
authored
3 years ago
by
James C Bowden
Browse files
Options
Download
Email Patches
Plain Diff
fix getCompletions ideque --> icollection
parent
c6ad9364
master
No related merge requests found
Pipeline
#62714
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/edu/caltech/cs2/interfaces/ICollection.java
+10
-0
src/edu/caltech/cs2/interfaces/ICollection.java
src/edu/caltech/cs2/interfaces/ITrieMap.java
+1
-1
src/edu/caltech/cs2/interfaces/ITrieMap.java
src/edu/caltech/cs2/project07/MapsAutoCompleter.java
+2
-1
src/edu/caltech/cs2/project07/MapsAutoCompleter.java
with
13 additions
and
2 deletions
+13
-2
src/edu/caltech/cs2/interfaces/ICollection.java
View file @
1416f773
...
@@ -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.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/edu/caltech/cs2/interfaces/ITrieMap.java
View file @
1416f773
...
@@ -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
I
Deque
<
V
>
getCompletions
(
K
prefix
);
public
I
Collection
<
V
>
getCompletions
(
K
prefix
);
/**
/**
* Removes all elements from the trie.
* Removes all elements from the trie.
...
...
This diff is collapsed.
Click to expand it.
src/edu/caltech/cs2/project07/MapsAutoCompleter.java
View file @
1416f773
...
@@ -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
);
I
Deque
<
IDeque
<
Location
>>
options
=
locs
.
getCompletions
(
kpIterable
);
I
Collection
<
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
<>();
...
...
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