Category "vector"

How to move elements from a set to a vector efficiently?

I have a std::set<vector<int>> from which I would like to move (not copy) elements to a std::vector<vector<int>>. How do I do this? I t

c++: Remove Elements that are in one vector from another

I need to remove the elements that appear in Vector A and Vector B, but keep the elements that are only in Vector A. The vectors can be of any size, but are not

How to combine two vectors of references without consuming an iterator?

I want to combine two reference vectors and convert them into a vector of values without consuming an iterator. Situation: Generate vectors by iterating over sp

Emplace back thread on vector

Why this cause undefined behavior? #include <iostream> #include <thread> #include <vector> std::vector<std::thread> threads(3); void

Why is the vector subscript out of range?

I'm trying to code this really simple addition program for practice. It takes in a list of inputs and stores it in a vector. Then it grabs each consecutive elem

Is using a vector of boolean values slower than a dynamic bitset?

Is using a vector of boolean values slower than a dynamic bitset? I just heard about boost's dynamic bitset, and I was wondering is it worth the trouble. Can I

how do you insert the value in a sorted vector?

ALL, This question is a continuation of this one. I think that STL misses this functionality, but it just my IMHO. Now, to the question. Consider following c

Is it possible to split a vector into groups of 10 with iterators?

I have let my_vec = (0..25).collect::<Vec<_>>() and I would like to split my_vec into iterators of groups of 10: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; [1

C++ STL vector for existing data

Can I create an std::vector using my pre-existing data instead of it allocating new memory and copying the data? To be clearer, if I have a memory area (either

Adding a vector to matrix rows in numpy

Is there a fast way in numpy to add a vector to every row or column of a matrix. Lately, I have been tiling the vector to the size of the matrix, which can use

How to create matrix from java vector of vectors (Multidimentional Vector)

am trying to create vector of Vectors(2d) in java like multidimensional array. then to assign values to specific position in that matrix like what we do using m

How can I check if a matrix is an element of a list of matrices? in R

I'm pretty new to programming in R. I have a matrix of numbers mat, as well as a list of matrices matlist. I want to check if the matrix mat matches with (i.e

How is a Vector of Vector aligned in memory?

I understand as Set size of vector of vectors at run time describes, one can declare vector of vector as vector<vector<int> > ref; then resize t

comparator for sorting a vector contatining pointers to objects of custom class

By this question I am also trying to understand fundamentals of C++, as I am very new to C++. There are many good answers to problem of sorting a vector/list of

A way to get the local minima and maxima of a vector

I've been trying to retrieve the extrema of a vector that looks like this : [![First case][1]][1](source: noelshack.com) or like this : [![Second case][2]][2](s