@Test public void testSize() { ConcurrentRadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(getNodeFactory()); assertEquals(0, tree.size()); tree.put("TEST", 1); assertEquals(1, tree.size()); tree.put("TEAM", 2); assertEquals(2, tree.size()); tree.put("TOAST", 3); assertEquals(3, tree.size()); tree.remove("FOO"); assertEquals(3, tree.size()); tree.remove("TOAST"); assertEquals(2, tree.size()); tree.remove("TEAM"); assertEquals(1, tree.size()); tree.remove("TEST"); assertEquals(0, tree.size()); }
@Override public int size() { Deque<Node> stack = new LinkedList<Node>(); stack.push(this.root); int count = 0; while (true) { if (stack.isEmpty()) { return count; } Node current = stack.pop(); stack.addAll(current.getOutgoingEdges()); if (current.getValue() != null) { count++; } } }
ConcurrentRadixTree implements RadixTree<O>, PrettyPrintable, Serializable { @Override public int size() { Deque<Node> stack = new LinkedList<Node>(); stack.push(this.root); int count = 0; while (true) { if (stack.isEmpty()) { return count; } Node current = stack.pop(); stack.addAll(current.getOutgoingEdges()); if (current.getValue() != null) { count++; } } } }
ConcurrentRadixTree implements RadixTree<O>, PrettyPrintable, Serializable { @Override public int size() { Deque<Node> stack = new LinkedList<Node>(); stack.push(this.root); int count = 0; while (true) { if (stack.isEmpty()) { return count; } Node current = stack.pop(); stack.addAll(current.getOutgoingEdges()); if (current.getValue() != null) { count++; } } } ConcurrentRadixTree(NodeFactory nodeFactory); }
ConcurrentRadixTree implements RadixTree<O>, PrettyPrintable, Serializable { @Override public int size() { Deque<Node> stack = new LinkedList<Node>(); stack.push(this.root); int count = 0; while (true) { if (stack.isEmpty()) { return count; } Node current = stack.pop(); stack.addAll(current.getOutgoingEdges()); if (current.getValue() != null) { count++; } } } ConcurrentRadixTree(NodeFactory nodeFactory); @Override O put(CharSequence key, O value); @Override O putIfAbsent(CharSequence key, O value); @Override O getValueForExactKey(CharSequence key); @Override Iterable<CharSequence> getKeysStartingWith(CharSequence prefix); @Override Iterable<O> getValuesForKeysStartingWith(CharSequence prefix); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForKeysStartingWith(CharSequence prefix); @Override boolean remove(CharSequence key); @Override Iterable<CharSequence> getClosestKeys(CharSequence candidate); @Override Iterable<O> getValuesForClosestKeys(CharSequence candidate); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForClosestKeys(CharSequence candidate); @Override int size(); @Override Node getNode(); }
ConcurrentRadixTree implements RadixTree<O>, PrettyPrintable, Serializable { @Override public int size() { Deque<Node> stack = new LinkedList<Node>(); stack.push(this.root); int count = 0; while (true) { if (stack.isEmpty()) { return count; } Node current = stack.pop(); stack.addAll(current.getOutgoingEdges()); if (current.getValue() != null) { count++; } } } ConcurrentRadixTree(NodeFactory nodeFactory); @Override O put(CharSequence key, O value); @Override O putIfAbsent(CharSequence key, O value); @Override O getValueForExactKey(CharSequence key); @Override Iterable<CharSequence> getKeysStartingWith(CharSequence prefix); @Override Iterable<O> getValuesForKeysStartingWith(CharSequence prefix); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForKeysStartingWith(CharSequence prefix); @Override boolean remove(CharSequence key); @Override Iterable<CharSequence> getClosestKeys(CharSequence candidate); @Override Iterable<O> getValuesForClosestKeys(CharSequence candidate); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForClosestKeys(CharSequence candidate); @Override int size(); @Override Node getNode();  }