i need to write a template with Nodes containing data with 2 data structures : a map and a minimum heap, both got the same nodes in it and every 2 same nodes are connected.
the problem is that i need the heap to know the node fields for the heapify for example, and i don’t know what’s the right way to do so, friends? public fields in Node? writing the Node inside the heap? using getters and setters?
thanks all for your help.
i need to write a template with Nodes containing data with 2 data structures
Share
Well, a linked list might be laid out like this:
There is no particular reason to hide the Node struct from the user or the LinkedList class (putting it into a detail namespace should be more than enough): LinkedList needs it and the Node itself is pretty much useless to the user. All encapsulation is up to LinkedList to achieve: it just shouldn’t give out it’s head (or any other
Node*).