Counting members of ConcurrentRadixTree?

42 views
Skip to first unread message

Tom Pierce

unread,
Dec 2, 2013, 10:48:18 PM12/2/13
to concurrent-t...@googlegroups.com
What is the best approach to getting the count of keys and/or values in a RadixTree? I have been using:
 
Iterables.count(myTree.getValuesForClosestKeys(""))

Is this the best approach? 

Niall

unread,
Dec 3, 2013, 5:06:14 PM12/3/13
to concurrent-t...@googlegroups.com
Hi Tom,

That approach is fine.

For a radix tree, 

Iterables.count(myTree.getValuesForKeysStartingWith(""))

is also option for calculating number of keys/values stored, as all keys are considered to start with an empty string.

I'll consider adding a size() method in future which would make this more obvious/straightforward.

Note that calculating the size (number of keys/values) of the tree is an O(n) operation, so is quite expensive as it requires the whole tree to be traversed.

Niall

unread,
Dec 3, 2013, 5:52:47 PM12/3/13
to concurrent-t...@googlegroups.com
I've implemented tree.size() methods on the trees. You can track it in issue 8.
Reply all
Reply to author
Forward
0 new messages