tagged [vector]

Delete all items from a c++ std::vector

Delete all items from a c++ std::vector I'm trying to delete everything from a `std::vector` by using the following code but it doesn't work. --- Update: Doesn't clear destruct the elements held by th...

7 Jun at 07:15

How to draw vectors (physical 2D/3D vectors) in MATLAB?

How to draw vectors (physical 2D/3D vectors) in MATLAB? I want to know the simplest way to plot vectors in [MATLAB](http://en.wikipedia.org/wiki/MATLAB). For example: I want to visualize this vector a...

27 Dec at 16:18

How can I insert element into beginning of vector?

How can I insert element into beginning of vector? I need to insert values into the beginning of a `std::vector` and I need other values in this vector to be pushed to further positions for example: s...

10 Jul at 13:15

Subtracting 2 lists in Python

Subtracting 2 lists in Python Right now I have vector3 values represented as lists. is there a way to subtract 2 of these like vector3 values, like Should I use tuples? If none of them defines these o...

9 Oct at 12:9

C# equivalent of C++ vector, with contiguous memory?

C# equivalent of C++ vector, with contiguous memory? What's the C# equivalent of C++ vector? I am searching for this feature: To have a dynamic array of contiguously stored memory that has no performa...

4 Aug at 14:56

How to access the last value in a vector?

How to access the last value in a vector? Suppose I have a vector that is nested in a dataframe with one or two levels. Is there a quick and dirty way to access the last value, without using the `leng...

1 Jan at 14:54

Initializing a two-dimensional std::vector

Initializing a two-dimensional std::vector So, I have the following: and I am initializing it very naively like: ``` for(int i=0; i fogRow; for(int j=0; j

6 Feb at 02:52

What is the easiest way to initialize a std::vector with hardcoded elements?

What is the easiest way to initialize a std::vector with hardcoded elements? I can create an array and initialize it like this: How do I create a `std::vector` and initialize it similarly elegant? The...

4 Mar at 14:16

In C++ check if std::vector<string> contains a certain value

In C++ check if std::vector contains a certain value Is there any built in function which tells me that my vector contains a certain element or not e.g.

27 Feb at 03:43

Angle between two Vectors 2D

Angle between two Vectors 2D I'm trying to compute the angle between two vectors. I tried this, but it always returns zero: [](https://i.stack.imgur.com/sVPA2.png)[](https://i.stack.imgur.com/77Mf3.pn...

11 Apr at 09:24

C++ STL Vectors: Get iterator from index?

C++ STL Vectors: Get iterator from index? So, I wrote a bunch of code that accesses elements in an stl vector by index[], but now I need to copy just a chunk of the vector. It looks like `vector.inser...

25 May at 09:28

Extract every nth element of a vector

Extract every nth element of a vector I would like to create a vector in which each element is the `i+6th` element of another vector. For example, in a vector of length 120 I want to create another ve...

29 Nov at 10:45

How can I get a field from the last element of a vector in C++?

How can I get a field from the last element of a vector in C++? I have a vector of structures. Such a structure has elements `int a, int b, int c`. I would like to assign to some `int var` the element...

15 Feb at 20:42

How to navigate through a vector using iterators? (C++)

How to navigate through a vector using iterators? (C++) The goal is to access the "nth" element of a vector of strings instead of the [] operator or the "at" method. From what I understand, iterators ...

7 Mar at 05:44

How do I pass multiple ints into a vector at once?

How do I pass multiple ints into a vector at once? Currently when I have to use `vector.push_back()` multiple times. The code I'm currently using is Is there a way to only use `vector.push_back()` on...

28 Jul at 16:22

How to rotate 2d vector?

How to rotate 2d vector? I have this: When I call the result is: `[-0.59846006905785809, -0.8

2 Apr at 17:29

How do I calculate the normal vector of a line segment?

How do I calculate the normal vector of a line segment? Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector perpendicular to the line? I can find lots of ...

7 Aug at 08:35

C++ trying to swap values in a vector

C++ trying to swap values in a vector This is my swap function: And this is my function (on a side note v stores strings) call to swap values but whenever I try to call using values in a vector I get ...

3 Jun at 08:44

Split a vector into chunks

Split a vector into chunks I have to split a vector into n chunks of equal size in R. I couldn't find any base function to do that. Also Google didn't get me anywhere. Here is what I came up with so f...

29 Sep at 16:13

Do I use <img>, <object>, or <embed> for SVG files?

Do I use , , or for SVG files? Should I use ``, ``, or `` for loading SVG files into a page in a way similar to loading a `jpg`, `gif` or `png`? What is the code for each to ensure it works as well as...

10 Sep at 16:5

Best way to extract a subvector from a vector?

Best way to extract a subvector from a vector? Suppose I have a `std::vector` (let's call it `myVec`) of size `N`. What's the simplest way to construct a new vector consisting of a copy of elements X ...

10 May at 06:9

Convert a dataframe to a vector (by rows)

Convert a dataframe to a vector (by rows) I have a dataframe with numeric entries like this one I was able to get it using the following, but I guess there should be a much more elegant way ``` X

4 Apr at 06:55

Convert Mat to Array/Vector in OpenCV

Convert Mat to Array/Vector in OpenCV I am novice in OpenCV. Recently, I have troubles finding OpenCV functions to convert from Mat to Array. I researched with .ptr and .at methods available in OpenCV...

31 Oct at 19:3

Using atan2 to find angle between two vectors

Using atan2 to find angle between two vectors I understand that: `atan2(vector.y, vector.x)` = the angle between the . But I wanted to know how to get the angle between using atan2. So I came across t...

5 Aug at 19:34

Why is Java Vector (and Stack) class considered obsolete or deprecated?

Why is Java Vector (and Stack) class considered obsolete or deprecated? Why is Java Vector considered a legacy class, obsolete or deprecated? Isn't its use valid when working with concurrency? And if ...

16 May at 00:28