C++ STL vector

C++ examples for STL:vector

Description

Click the following links for the tutorial for STL and vector.

  1. Creating a vector that holds integers
  2. Specializing STL vector, store int value in vector
  3. Vector insert and erase
  4. Using Uniform Initialization to Construct a vector
  5. Initializing Objects with Initializer Lists
  6. Explicit initializer_list Usage
  7. Storing a Growing Number of Objects Using STL vector
  8. Resizing a vector


  9. Reducing the capacity of a vector
  10. Removing elements from a vector
  11. Adding elements to arbitrary points in a vector
  12. Use the capacity method to determine how many elements the vector is capable of storing before it will resize.
  13. Bounds-checking on vectors
  14. Storing Strings in a Sequence, Use a vector for array-like storage of your strings.
  15. Storing Pointers in a vector
  16. Copying a vector, copy the contents of one vector into another.


  17. Using vectors Instead of Arrays to store built-in types, objects, pointers, etc. in a sequence
  18. Demonstrating C++ Standard Library class template vector.
  19. Recursively Find the Minimum Value in a vector
  20. Use vector to track Dice Rolling random number
  21. Use a vector of integers to track value range
  22. Bucket Sort on vector of positive integers
  23. Enhanced Bubble Sort on vector of number
  24. Bubble Sort on vector of number
  25. Merge Sort vector of number
  26. Quick sort on vector
  27. Recursive Binary Search on vector of integer
  28. Recursive Linear Search on vector
  29. Binary search to find an integer from a vector
  30. Vector class element at, erase, insert functions.
  31. Working with a vector container to add integer value
  32. Outputting product records & cost, Getting the alignment right.
  33. Storing double type numbers in a vector
  34. Storing student ages in dynamic array containers
  35. Storing student names and grades in two vectors
  36. Frequency of words in text.
  37. Sorting an array in ascending sequence - using a vector<T> container
  38. The Capacity and Size of a Vector
  39. Using std::vector<T> Containers
  40. Demonstrate push_back(), operator[], size() on vector
  41. Demonstrate insert(), erase() on vector
  42. Demonstrate constructors, swap(), empty(), back(), pop_back() on vector
  43. Vector to string objects, push_back(), and []
  44. Create vector of int and add value to the vector
  45. Reserve space for 50 elements in vector
  46. Resize a vector
  47. Show the size and capacity of vector.
  48. Create an empty vector and then assign it a sequence that is the reverse of another vector.
  49. Change vector element values using array subscript syntax
  50. Create another vector that contains a subrange of vector.
  51. Cycle through vector in the reverse direction using a reverse_iterator.
  52. Cycle through vector in the forward direction using an iterator.
  53. Declare reverse iterator to a vector<int>
  54. Declare an iterator to a vector<int>.
  55. Get the first and last element from vector using rbegin() and rend()
  56. Get the first and last element from vector using begin() and end()
  57. Use pop_back() to remove one element from vector.
  58. Add elements to the end of vector using push_back member function.
  59. Compute the average of the values in vector using array subscripting operator.
  60. Assign elements to vector using array-subscripting syntax.
  61. Exchange the contents of vector 1 and vector 3.
  62. Insert element to vector at the end
  63. Remove the first element from vector
  64. Insert element at the start of vector
  65. Determine if one vector is less than vector with lexicographical compare.
  66. Insert more characters into vector at the end.
  67. Compare two vector containers.
  68. Show the size of vector, which is the number of elements
  69. Create another vector that is the same as the first vector
  70. Use a reverse iterator to show the contents of vector in reverse.
  71. Declare a reverse iterator for vector.
  72. Insert characters into vector. An iterator to the inserted object is returned.
  73. Obtain an iterator to the start of vector.
  74. Declare an iterator to a vector<char>.
  75. Declare an empty vector that can hold char objects.
  76. Store user-defined objects in a vector.
  77. Extract Sentences from a Vector of Characters