views:

42

answers:

1

I am building a tree like data structure. What is the expected behavior if I have a method

public Set getSiblingNodes(Node node);

Should this method return a set including or excluding itself?

Thanks!

+2  A: 

No. It should contain only it's siblings.
A node is not a sibling of itself.
(Why would you think otherwise?)

Oren A
The formal definition of sibling is "If node x and node y share the same parent node, they are siblings". If x and y are the same node, that statement still holds true. I agree with you, however.
DexterW