I have to fill an array of 1000 objects by reading data from disk. However, not every objects exits.
Once I declare an array, memory will be reserved for 1000 objects. As I read them one by one, I set the memory to corresponding values. However, there might not be an object for member #276 and it's memory will remain set to whatever was there when the array was declared.
How do I keep the information that certain member of the array is invalid/doesn't exist?
I could somehow set all the bytes of the member to zero, but that might be a valid object.
The obvious solution is adding another array of bytes that will be set to 1 or 0 depending whether the object at that index exists, but it doesn't seem very elegant.
Could this be done with a vector instead? Can it somehow store an empty value?