findTreeParentChain ordered or unordered collection?

Continuing the discussion from Path of a node TreeView:

Here you suggest to use findTreeParentChain to get the path in a tree. However, this method returns a set which is an unordered collection.

Shouldn’t it return a list instead if it is actually ordered?

The Nodes and Links are added starting from the given node and walking up the parent chain. Sets maintain the order in which things were added, called the “insertion order”, but you cannot change the order because there’s no sort method. In v3, the GoJS Set class uses the built-in JavaScript Set class, for example: Set.prototype.forEach() - JavaScript | MDN

In GoJS v1.0 there wasn’t any built-in JavaScript Set or Map class, so we had to design and implement our own. Times have changed…

1 Like