- Nov 29, 2005
- 2,411
- 0
- 0
So here's the situation:
*** if you're interested ***
I'm dealing with a dataflow graph, and I'm building a map of symbols (of the form symbolName => graphNodeNumber). I use a multimap because there can multiple entries of the same symbol in the map. So when I encounter a new symbol, I want to check the map, see if it exists, if it doesn't, add it (actually, I add it regardless) and then manipulate the previous entries in the map (i.e. I use the symbolName to get access to the other nodes in the graph that have that symbol, and then manipulate those nodes).
*** /if you're interested ***
So here's the question: technically, I only need to edit the "last" node I saw, assuming that the multimap entry returns the "last" one entered. Ya dig? So, it'd go like this:
1. See symbol "a" at node 4. Search map, return null. Add to map (entry 1)
2. See symbol "a" at node 5. Search map, return entry 1. Edit entry 1. Add to map (entry 2).
3. See symbol "a" at node 8. Search map, return entry 2. Edit entry 2. Add to map (entry 3).
etc
etc
Otherwise, I need to return an iterator (or, actually, 2 iterators) with a range of entries, and then edit them all. Or, actually, I'll only need to edit one of them, but I'm not sure which one it'll be that I'll need to edit.
So can I just use a find operation on the multimap and it'll give me the one I want?
Any other datastructures I should be using? I do know there's a million ways to do this.
*** if you're interested ***
I'm dealing with a dataflow graph, and I'm building a map of symbols (of the form symbolName => graphNodeNumber). I use a multimap because there can multiple entries of the same symbol in the map. So when I encounter a new symbol, I want to check the map, see if it exists, if it doesn't, add it (actually, I add it regardless) and then manipulate the previous entries in the map (i.e. I use the symbolName to get access to the other nodes in the graph that have that symbol, and then manipulate those nodes).
*** /if you're interested ***
So here's the question: technically, I only need to edit the "last" node I saw, assuming that the multimap entry returns the "last" one entered. Ya dig? So, it'd go like this:
1. See symbol "a" at node 4. Search map, return null. Add to map (entry 1)
2. See symbol "a" at node 5. Search map, return entry 1. Edit entry 1. Add to map (entry 2).
3. See symbol "a" at node 8. Search map, return entry 2. Edit entry 2. Add to map (entry 3).
etc
etc
Otherwise, I need to return an iterator (or, actually, 2 iterators) with a range of entries, and then edit them all. Or, actually, I'll only need to edit one of them, but I'm not sure which one it'll be that I'll need to edit.
So can I just use a find operation on the multimap and it'll give me the one I want?
Any other datastructures I should be using? I do know there's a million ways to do this.