iterator


1. Vector Iteration with Iterator

#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> vec = {1, 2, 3, 4, 5};
  vector<int>::iterator it;

  for (it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }

  cout << endl;
  return 0;
}

2. String Iteration with Iterator

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str = "Hello World";
  string::iterator it;

  for (it = str.begin(); it != str.end(); ++it) {
    cout << *it;
  }

  cout << endl;
  return 0;
}

3. List Iteration with Iterator

4. Array Iteration with Iterator

5. Map Iteration with Iterator

6. Unordered Map Iteration with Iterator

7. Set Iteration with Iterator

8. Unordered Set Iteration with Iterator

9. Queue Iteration with Iterator

10. Priority Queue Iteration with Iterator

11. Stack Iteration with Iterator

12. Deque Iteration with Iterator

13. Forward List Iteration with Iterator

14. Array Iteration Using Iterator and For-Each Loop

15. Vector Iteration Using Iterator and For-Each Loop

16. List Iteration Using Iterator and For-Each Loop

17. Map Iteration Using Iterator and For-Each Loop

18. Unordered Map Iteration Using Iterator and For-Each Loop

19. Set Iteration Using Iterator and For-Each Loop

20. Unordered Set Iteration Using Iterator and For-Each Loop

21. Queue Iteration Using Iterator and For-Each Loop

22. Priority Queue Iteration Using Iterator and For-Each Loop

23. Stack Iteration Using Iterator and For-Each Loop

24. Deque Iteration Using Iterator and For-Each Loop

25. Forward List Iteration Using Iterator and For-Each Loop

26. Using Iterator to Insert and Delete Elements in Vector

27. Using Iterator to Find Element in Vector

28. Using Iterator to Sort Vector

29. Using Iterator to Reverse Vector

30. Using Iterator to Copy Vector