About 11,900,000 results
Open links in new tab
  1. What are vectors and how are they used in programming?

    This pair (3, 4) is also a mathematical vector. In programming, this name "vector" was originally used to describe any fixed-length sequence of scalar numbers. A vector of length 2 represents a point in a …

  2. Is std::vector so much slower than plain arrays? - Stack Overflow

    Sep 8, 2010 · vector is implemented as an array. That's not "conventional wisdom", its the truth. You've discovered that vector is a general purpose resizable array. Congratulations. As with all general …

  3. std::vector versus std::array in C++ - Stack Overflow

    Dec 12, 2010 · std::vector is a template class that encapsulate a dynamic array 1, stored in the heap, that grows and shrinks automatically if elements are added or removed. It provides all the hooks …

  4. Arrays vs Vectors: Introductory Similarities and Differences

    Feb 26, 2013 · A vector is a dynamically-sized sequence of objects that provides array-style operator[] random access. The member function push_back copies its arguments via copy constructor, adds …

  5. c++ - Vector of Vectors to create matrix - Stack Overflow

    I am trying to take in an input for the dimensions of a 2D matrix. And then use user input to fill in this matrix. The way I tried doing this is via vectors (vectors of vectors). But I have encount...

  6. When should I use vector::at instead of vector::operator []?

    Since it is unlikely that an out of bounds access to a vector is part of the normal program flow (in the case it is, you're right: check beforehand with size instead of letting the exception bubble up), I agree …

  7. Initializing the size of a C++ vector - Stack Overflow

    This is a crucial piece of information as when using pointer classes, which also initialise the objects (maybe with new), the vector<Entry> phone_book (n); until c++11 would actually copy the address n …

  8. How to sum up elements of a std::vector? - Stack Overflow

    What are the good ways of finding the sum of all the elements in a std::vector? Suppose I have a vector std::vector<int> vector with a few elements in it. Now I want to find the sum of all the

  9. Iterate through a C++ Vector using a 'for' loop - Stack Overflow

    Oct 3, 2012 · I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the first parameter of the for loop is always

  10. c++ - What's faster, iterating an STL vector with vector::iterator or ...

    I have been doing benchmarks myself, and vector.at is much slower than using an iterator, however using vector [i] is much faster than using an iterator. However, you can make the loop even faster by …