@Test public void getAllTest() { List<Item> items = createitems("elma", "el", "arm", "armut", "a", "elmas"); additems(items); List<Item> all = lt.getAll(); Assert.assertEquals(6, all.size()); }
public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) { n.addAll(tNode.children.getValues()); } } toWalk = n; } return items; }
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) { n.addAll(tNode.children.getValues()); } } toWalk = n; } return items; } }
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) { n.addAll(tNode.children.getValues()); } } toWalk = n; } return items; }  }
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) { n.addAll(tNode.children.getValues()); } } toWalk = n; } return items; }  void add(String s, T item); void remove(String s, T item); int size(); boolean containsItem(String s, T item); List<T> getItems(String s); List<T> getAll(); List<T> getPrefixMatchingItems(String input); String toString(); }
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) { n.addAll(tNode.children.getValues()); } } toWalk = n; } return items; }  void add(String s, T item); void remove(String s, T item); int size(); boolean containsItem(String s, T item); List<T> getItems(String s); List<T> getAll(); List<T> getPrefixMatchingItems(String input); String toString();  }