Discussion Overview
The discussion revolves around the best container for storing vectors in C++, specifically focusing on the use of a vector of vectors. Participants explore the capabilities of different standard containers and how to manipulate them for matrix-like structures.
Discussion Character
- Technical explanation
- Conceptual clarification
- Debate/contested
Main Points Raised
- One participant asks if it is possible to declare a vector whose elements are vectors and suggests using a vector of vectors for accessing specific elements while allowing for addition and removal.
- Another participant confirms that a vector of vectors is possible, along with other combinations of standard containers, and provides an example of initializing a matrix using a vector of vectors.
- A participant expresses the need to use push_back to add vectors to form a matrix and inquires about how push_back would affect the structure (rows or columns).
- One participant suggests that the original question may be misleading, arguing that it pertains more to the Standard Template Library (STL) than to C++ itself.
- Another participant clarifies that push_back is used to add a vector to a vector of vectors and explains how this relates to the representation of matrices.
- A later reply provides code to demonstrate how to use push_back to append rows to a matrix represented by a vector of vectors.
- One participant notes that using push_back can lead to rows of different lengths, introducing the concept of a "ragged matrix" and how to traverse it correctly.
Areas of Agreement / Disagreement
Participants generally agree on the feasibility of using a vector of vectors and the functionality of push_back, but there are differing views on the implications of the original question regarding C++ versus STL. The discussion remains unresolved regarding the best practices for using these containers.
Contextual Notes
Some participants mention limitations regarding the interpretation of matrix representations and the potential for varying row lengths in a vector of vectors.