My legacy code uses a red-black tree to store pointers to homogeneous (typically POD) objects. Let's call one MyPod
. My compare function compares pointers to two such objects based on whatever criteria is required. What I'm trying to find isn't a SECOND thing, but just the pointer already in the red-black tree.
To use std::map<>
I think I'd have to map std::Map<MyPod*, MyPod*>
? Seems wasteful to have the same pointer twice. Is there another collection I should consider? Can I make the second item void
, or replace the pair<>
with a single pointer, or make the pair
a union
, or something?
You can just use std::set<MyPod*>
instead of a std::Map<MyPod*, MyPod*>
.