0
I have a method keysWithPrefix for the purpose of returning all Keys starting with an input value that is specified as in the implementation below:
public Iterable<String> keysWithPrefix(String pre) {
Queue<String> q = new Queue<String>() {
collect(get(root, pre, 0), pre, q);
return q;
}
private void collect(Node x, String pre, Queue<String> q) {
if (x == null) return;
if (x.val != null) q.add(pre);
for (char c = 0; c < R; c++)
collect(x.next[c], pre + c, q);
}
But I don’t know how to print the return on the screen. This method returns an Iterable string
I believe you’ve mistaken for
Iterator
– Jefferson Quesado
I forgot to put the method that calls the
iterator
, Thanks @Jeffersonquesado, already made the adjustment.– Andre Gusmao