Sequences
Lists of any kind are the most essential data structure in a typical program; they provide flexibility and can be used as a queue, as a stack, as well as a searchable structure. Yet the limitations and the operations make a huge of difference between different data structures, which is why the documentation for std::collections
offers a decision tree to find out the collection type that is actually required to solve a particular problem.
The following were discussed in Chapter 14, Lists, Lists, More Lists:
- Dynamic arrays (
Vec<T>
) are the most universal and straightforward to use sequential data structure. They capture the speed and accessibility of an array, the dynamic sizing of a list, and they are the fundamental building block for higher order structures (such as stacks, heaps, or even trees). So, when in doubt aVec<T>
is always a good choice. VecDeque<T>
is a close relative of theVec<T>
, implemented as a ring buffer—a dynamic array that wraps around...