I have a set of tree objects with depth somewhere in the 20s. Each of the nodes in this tree needs access to the root of the tree.
A few solutions:
Can someone provide a design that does not use global (in any case), but is more efficient than # 1 or # 2 respectively in memory or loops?
Edit: Since I have a set of trees, I cannot just store it in statics, as it would be difficult to distinguish between trees. (thanks maccullt)
, node .
: :
, , 5.
? , , .
: . , " ". , . , , .
, , . + , . , ( ) . Process Explorer.
: , , node, 55 . . , O (1). , O (m * n), FindNodeByID.
. - , root.
№ 1 - . # 2 - . , , ? , "", ?
№2. , -, , , , - . , - , . (, , node , , ?) , .
TreeView, singleton. , , , , , .
Ignoring the aversion to inner classes, I could define a tree class and define nodes as inner classes. Each of the nodes will have access to its tree, including its root.
This may turn out to be the same as # 1 depending on how Java associates nodes with parents. (I'm not sure, and I will have to comment on it)
Source: https://habr.com/ru/post/1696911/More articles:ASP.NET 2.0: skin files only work when placed in the root folder of the theme? - asp.netIs there any way to pass the structure type of the function c - chow to get free amount of free apaches in php - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1696909/simple-free-or-cheap-tool-for-rolling-out-windows-xp-standardized-apps-to-a-small-computer-lab&usg=ALkJrhjiNj7-xv4lAn-tEC_B7joQRsKZ1QHow to host an external application in WPF? - externalNeed a wiki where I can export to Word - ms-wordDoes anyone use ASP.NET MVC Framework on live sites? - web-applicationsRefactoring and source control: how? - version-controlA design problem with sorting types with many different subclasses - c #"Победа" OO программирует собеседование с опытом sysadmin/Perl/Linux? - oopAll Articles