Skip to main content
10 events
when toggle format what by license comment
Jul 22, 2019 at 19:48 history edited dfhwze CC BY-SA 4.0
added check
Jul 22, 2019 at 19:16 vote accept Stacklysm
Jul 22, 2019 at 19:05 history edited dfhwze CC BY-SA 4.0
added 27 characters in body
Jul 22, 2019 at 19:02 comment added Stacklysm I was worried about changing the code (which isn't allowed here). As you said, once there are sufficient suggestions, I'll do a follow-up. And again, thanks for you time spent into this matter :)
Jul 22, 2019 at 19:01 comment added dfhwze Once this question has sufficient answers, you can always ask a follow-up question with the new code. I will be happy review that question as well. For now, I can say, this new check does not cover all edge cases :)
Jul 22, 2019 at 18:59 comment added Stacklysm Ok. About the addition of new children, I'm doing the following check: return !node.Children.Contains(this) && node != this && !Children.Contains(node);. If it's false, then ArgumentException is thrown.
Jul 22, 2019 at 18:57 comment added dfhwze I used recursion in GetDescendants because you have tagged your question as such. It is also possible without. I am sure someone will review that part.
Jul 22, 2019 at 18:55 comment added Stacklysm Thank you for taking your time and reviewing the code. Apparently I was paranoid that my first implementation of this method would mess up with the original object. I fixed the following: A) IsRoot code (now, if the parent is not set, then it's considered as the root Parent == null; B) Removed the null check on Children; C) Search method now returns immutable copies of the descendants
Jul 22, 2019 at 18:52 history edited dfhwze CC BY-SA 4.0
added 347 characters in body
Jul 22, 2019 at 18:42 history answered dfhwze CC BY-SA 4.0