You should probably look at stl::set for what you need. A stl::bitset is another option.
This will depend on how you need to use the information, which will determine which one is better. A set is a sorted data structure, insert, search and delete is O (LOG N) time. But if you need to iterate over all the values that you have noted for "existence", then set is the way to go.
If you only need to point out and find the fact that something is a member of the set, then bitset might be better for you. Insert, search and delete only accept O (1), but you can only collect int values. Iterating over all the marked values will take O (N), since you need to go through the whole set to find elements that are set to true . You can use it in conjunction with stl :: map to map the values you have with the numeric values of bitset .
Look at the operations you need to perform with the values in your set and you can select the appropriate data structure
source share