access the first element, in amortized constant time. Front Insertion Sequences have special member functions as a shorthand for those operations.
Sequence
None, except for those of Sequence.
X
A type that is a model of Front Insertion Sequence
a
Object of type
T
The value type of
t
Object of type
In addition to the expressions defined in Sequence, the following expressions must be valid.
Name | Expression | Type requirements | Return type |
---|---|---|---|
Front | a.front() [1] | ||
Push front | a.push_front(t) |
| |
Pop front | a.pop_front() | void |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Front | a.front() [1] | !a.empty() | Equivalent to | |
Push front | a.push_front(t) | Equivalent to | ||
Pop front | a.pop_front() | !a.empty() | Equivalent to |
Front, push front, and pop front are amortized constant time. [2]
Symmetry of push and pop |
• list
• deque
[1] Front is actually defined in Sequence, since it is always possible to implement it in amortized constant time. Its definition is repeated here, along with push front and pop front, in the interest of clarity.
[2] This complexity guarantee is the only reason that
Container, Sequence, Back Insertion Sequence,
Back Insertion Sequence