I’m using data trees to cast some i.e. integers to branches so in every branch when every item is casted I want to modify the branch and make it a unique list , is it proper to use system.Linq method to modify the list to a list of unique elements , like this : mylist.Distinct().ToList();
- Is it possible to modify the branch(list) in a tree instead of looping and casting each branch again to a list then make it distinct?
- And after that how to replace the modified branch in the tree instead of making a new tree ?
1.) No, because .Distinct().ToList() returns a new list, so you need to replace the old (branch-)list. Generally seen lists are optimised for adding items not removing. There are other data structures more suited.
2.) I’m not quite sure, but in my opinion you cannot directly replace branches. You can clear a tree and add new data. But there is no reason to do so. What speaks against writing a new tree? In addition to that. You are looping through it anyways. No matter if directly or indirectly.
Furthermore, it makes sense to use DataTree’s like intended: You get one in, you do something, you give a new one out. I think Datatrees are not supposed to be modified after filling it with data. Its a simplification of the GH_Structure class.
I basically found that List of List could be much better because one can modify any list in it without casting elements to separate one (unlike trees : a little weak for here) . I’m sure trees could be so useful