I have a problem where the data is represented in form of a tree (Ex: binary tree). The tree has nodes of different kind. So basically, there is a base class and then different nodes are derived from it.
This data also needs to be presented on the screen (to the user) and this involves custom drawing of each nodes. How the node is drawn depends on the type of the node. The tree also involves simplification process using which a new simplified form of the original tree is derived based on some rules.
In order to draw these nodes I need to maintain the position and size. I’d like to know how I can separate this code and data required to draw the tree on the screen from the other data in the node that will be used for simplification.
I hope the question made sense. Thanks for the help and time.
It’s not so clear what you mean as “maintain the position and size”.
If you mean that given a node N that belongs to a Tree (T), it has the same parent and same children, you will clarify us if the transformation you apply to the T to get the simplified one (T1) outcomes a different tree or an homomorphic tree.
I don’t know very well Objective C, but the question you ask us it seems general for every OOP language.
Given N the node you use in the tree T, you can declare an Inner Class “NData” inside the base class of N. So every node derived class will have the NData data to use in the simplification process.
I hope I understood the question 🙂