A few times I use a restricted interface over a vector
or another mutable sequence ( a sequence adapter) which only allows push_back
and clear
. It has some nice property such as, an iterator can be designed based on index which is always stable (like stable_vector
but also has element contiguity) and hence can be stored without fear of invalidation unless it is cleared.
I want to use a adapter class instead of vector
or another sequence directly to emphasize the interface (as well as to prevent any accidental mistake using unsupported operations such as insert
, erase
etc).
Is there any existing ADT which matches with this append_only
sequence? Otherwise can anyone recommend a suitable name for this sequence adapter?
There are four main types of different sequences you need to know, they are arithmetic sequences, geometric sequences, quadratic sequences and special sequences.
Finite sequence: {4,8,12,16,…, 64} The first of the sequence is 4 and the last term is 64 . Since the sequence has a last term, it is a finite sequence.
Types of Sequence and SeriesArithmetic Sequences. Geometric Sequences. Harmonic Sequences. Fibonacci Numbers.
The Fibonacci sequence is a set of integers (the Fibonacci numbers) that starts with a zero, followed by a one, then by another one, and then by a series of steadily increasing numbers. The sequence follows the rule that each number is equal to the sum of the preceding two numbers.
I don't think there is any existing ADT to do what you want. As for the name I would go with PushOnlyVector
or something of the kind. In fact I also like the append_only
in your question so you may also make use of it: AppendOnlyVector
. And one last option: GrowingArray
. I keep the vector
or array
as part of the name to emphasize you support index operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With