... stack
adapter because a deque
grows more efficiently than a vector
. A vector
is maintained as a contiguous block of memory—when that block is full and a new element is added, the vector
allocates a larger contiguous block of memory and copies the old elements into that new block. A deque
, on the other hand, is typically implemented as a list of fixed-size, built-in arrays—new fixed-size built-in arrays are added as necessary and none of the existing elements are copied when new items are added to the front or back. For these reasons, we use a deque
(line 36) as the underlying container for our Stack
class.
18.2.3 Class Template Stack<T>
’s Member Functions
The member-function definitions of a class template are function templates, but are not preceded ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.