Currently, it seems that the implementation of DSForests assumes that the user knows about DSNode and thus can access its public fields. Is this a good thing in this case? My first intuition is that the user doesn't care about these implementations details and therefore they should be hidden. Note: if that's the case, we may need also to change the interface of certain methods, e.g. find, which instead of returning DSNode would return the original value stored in the corresponding representative.
For example, Kruskal's MST algorithm uses DSForests, but doesn't really care about implementation details, it only cares about the main functionalities and advantages that DSForests uses:
Find if two elements belong to the same set in amortized constant time
The nature of the DS, i.e. that you have a forest of disjoint sets and you can union them.
Currently, it seems that the implementation of
DSForests
assumes that the user knows aboutDSNode
and thus can access its public fields. Is this a good thing in this case? My first intuition is that the user doesn't care about these implementations details and therefore they should be hidden. Note: if that's the case, we may need also to change the interface of certain methods, e.g.find
, which instead of returningDSNode
would return the original value stored in the corresponding representative.For example, Kruskal's MST algorithm uses
DSForests
, but doesn't really care about implementation details, it only cares about the main functionalities and advantages thatDSForests
uses: