A suitable name for a sequence that only grows from one end

Several times I use a limited interface through vector or another mutable sequence (sequence adapter) that only allows push_back and clear . It has some nice property, such as, an iterator can be constructed based on an index that is always stable (for example, stable_vector , but also has an adjacency of elements) and, therefore, can be stored without fear of invalidation if it is not cleared.

I want to use an adapter class instead of vector or another sequence to emphasize the interface (and also to prevent an accidental error using unsupported operations such as insert , erase , etc.).

Is there any existing ADT that matches this append_only sequence? Otherwise, can anyone recommend a suitable name for this sequence adapter?

+8
c ++ containers sequence
source share
1 answer

I do not think there is any existing ADT to do what you want. As for the name, I would go with PushOnlyVector or something like that. Actually, I also like append_only in your question, so you can also use it: AppendOnlyVector . And the last option: GrowingArray . I save vector or array as part of the name to emphasize that you support the index operation.

+2
source share

All Articles