I want to represent threaded comments in Java. This would look similar to the way comments are threaded on reddit.com
hello
hello
hello
hello
hello
hello
hello
As in the example above, responses are nested in the HTML with appropriate indentation to reflect their relationship to prior comments.
What would be an efficient way to represent this in Java?
I'm thinking some kind of tree data structure would be appropriate.
But is there one in particular which would be most efficient to minimize tree traversals?
This would be important if I have voting on each comment. Because then the tree would need to be reordered after each vote - a potentially expensive operation computationally.
By the way, if anyone knows of an open source existing implementation of this in Java, that would help too.