Design a fast, growable Array<T> whose elements never change address once created, where at(index) creates a zero-initialised element on first access.
Unlock detailed company stats for this questionUpgrade
Design a fast, growable Array<T> class template. Once an element exists its address must never change until the array is destroyed. Storage need not be contiguous: elements may sit in separate blocks that are added as the array grows. T is zero-initialisable, meaning a block of zeroed memory is a valid T. Reading an index that does not exist yet must allocate it and zero-initialise it automatically, and random access by index must be fast. Implement T& at(size_t index), which creates the element if it is not there yet.
Community answers
No answers contributed by the community yet.
Related courses

Course

