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...
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...
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...
- Modified
- 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...
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...
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...
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
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...
- Modified
- 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.
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...
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...
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...
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...
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 ...
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...
How to rotate 2d vector?
How to rotate 2d vector? I have this: When I call the result is: `[-0.59846006905785809, -0.8
- Modified
- 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 ...
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 ...
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...
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...
- Modified
- 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 ...
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
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...
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 ...
- Modified
- 16 May at 00:28