DictionaryEnumerator.cpp 580 B

123456789101112131415161718192021222324252627282930
  1. #include "Dictionary.h"
  2. #include <iostream>
  3. #include <stdio.h>
  4. using namespace std;
  5. int main()
  6. {
  7. Dictionary<int, int> dict;
  8. int k = 20;
  9. for(int i=0; i<k; i++)
  10. dict[i] = 10*i;
  11. Dictionary<int, int>::Enumerator e = dict.getBegin();
  12. while (e.next())
  13. {
  14. cout << "[" << e.current().key << "," << e.current().value << "] ";
  15. }
  16. cout << endl;
  17. Dictionary<int, int>::Enumerator eb = dict.getEnd();
  18. while (eb.prev())
  19. {
  20. cout << "[" << eb.current().key << "," << eb.current().value << "] ";
  21. }
  22. cout << endl;
  23. getchar();
  24. }