I understand that you have std::vectorprealocated in a specific dimension, say n, and you want to find out if an element in index i( i < n) was initialized or just highlighted .
Like @Thomas Matthews, you can use a second data structure, a simple bool[n]one in which kyou store in the index trueif the element with the index kin yours vectorexists falseotherwise.
0 1 2 3 4 5
v = [ * * * * ]
0 1 2 3 4 5
exists = [ true, false, true, false, true, true ]
source
share