vectors (518)


c++ - Fast plane rotation algorithm?

c++ - Fast plane rotation algorithm?

I am working on an application that detects the most prominent rectangle in an image, then seeks to rotate it so that the bottom left of the rectangle rests at the origin, similar to how IUPR's OSCAR…


c++ - STL like container typedef shortcut?

A common pattern with STL containers is this: map<Key, Value> map; for(map<Key, Value>::iterator iter=map.begin(); iter != map.end();++iter){...}So in order to avoid writing the declaration…


Initializing a static std::map<int, int> in C++

What is the right way of initializing a static map? Do we need a static function that will initialize it?…


c++ - Concatenating two std::vectors

How do I concatenate two std::vectors?…


using STL to find all elements in a vector

I have a collection of elements that I need to operate over, calling member functions on the collection: std::vector<MyType> v;...// vector is populated For calling functions with no arguments it's…


c++ - How do I sort a std::vector by the values of a different std::vector?

I have several std::vector, all of the same length. I want to sort one of these vectors, and apply the same transformation to all of the other vectors. Is there a neat way of doing this?(preferably…


language agnostic - Calculating a 2D Vector's Cross Product

From wikipedia: the cross product is a binary operation on two vectors in a three-dimensional Euclidean space that results in another vector which is perpendicular to the plane containing the two in…


c++ - How to downsize std::vector?

Is there a way to resize a std::vector to lower capacity when I no longer need previously reserved space?…


How do you copy the contents of an array to a std::vector in C++ without looping?

I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called be…


Generic vector of vectors in C++

Is there a good way in C++ to implement(or fake) a type for a generic vector of vectors? Ignore the issue of when a vector of vectors is a good idea(unless there's something equivalent which is alw…





vector two how example array with between matrix and find