About 1,410,000 results
Open links in new tab
  1. c++ - 2D vector vs 1D vector - Stack Overflow

    In C++11, how does a 2D vector against 1D vector in terms of time? In the 2D vector given, all the inner vectors are of the same size. Ex: std::vector<std::vector<int>> X{10, std::vector<int>(4)}; …

  2. 2D Vector in C++ - GeeksforGeeks

    May 13, 2025 · A 2D vector is a vector of the vectors i.e. each element is a vector in itself. It can be visualised as a matrix where each inner vector represents a row, and the number of rows …

  3. How can I create a 1D vector from a 2D vector in C++?

    Dec 9, 2021 · If I have a 2D vector of size n x m and I want to create a 1D vector of size n with all the elements in column 0 of 2D vector, how can I achieve this with one line of code? Basically, …

  4. Multidimensional Vectors in C++ - GeeksforGeeks

    Nov 18, 2024 · In this article, we will primarily discuss these two multidimensional vectors and how to use them in a C++ program. In C++, 2D Vectors or Two-Dimensional Vectors are the …

  5. Vector of Vectors in C++ STL with Examples - GeeksforGeeks

    Feb 14, 2020 · Vector of Vectors is a two-dimensional vector with a variable number of rows where each row is vector. Each index of vector stores a vector which can be traversed and …

  6. Switching from a 2D vector into a 1D vector - Stack Overflow

    Dec 20, 2021 · It depends. For example if you resize rows often then a std::vector<std::vector<char>> might even perform better than a std::vector<char>. For sparse …

  7. How convert 2d vector to 1d array in C++? - Stack Overflow

    Jun 4, 2019 · I need to be able to do this without using C++ smart pointers. I tried the following double* VecToArr(std::vector<std::vector<double>> vec) { double* newarr=new …

  8. How to Insert Elements into 2D Vector in C++? | GeeksforGeeks

    Nov 22, 2024 · In this article, we will explore different ways to insert elements into a 2D vector in C++ and their specific use cases. The simplest way to add elements to a 2D vector is by …

  9. Can I convert my 1D vector to a 2D vector faster than this?

    Oct 31, 2020 · If what you want is to be able to access the data conveniently as if it was a 2D array, you can make a wrapper class that overloads the operator[] and returns a std::span (if …

  10. Converting 1d vector into 2d vector - Stack Overflow

    Apr 21, 2013 · I'm not aware of a method to automagically turn a 1D vector into a 2D one. It's not too hard to do manually, though... DoubleVector2D result; for (std::size_t i = 0; i < …

  11. Some results have been removed
Refresh