Word
ostream & operator << (ostream & s, const WordT & word){ s << word.Word() << " " << word.Count(); return s; }
vector<WordT> words;
void ReadWords(ifstream & inFile, vector<WordT> & words);
typedef vector<WordT> WordVectorT;
using WordVectorT = vector;
WordVectorT words; WordVectorT::iterator pos; ReadWord(ifstream & inFile, WordVectorT & words);
vector <WordT>::iterator pos;
pos
can now point to any element of a vector of WordT's
words
is such a vector.
words.begin()
or begin(words)
returns an iterator to the first element.
words.end()
or end(words)
returns an iterator to one past the last element.
for(pos = begin(words); pos != end(words); pos++) { cout <<setw(20) << pos->Word() << " " << pos->Count() << endl; }
void PrintList(const vector <WordT> & words){ vector <WordT>::const_iterator pos; for(pos = cbegin(words); pos != cend(words); pos++) { cout <<setw(20) << pos->Word() << " " <<<pos->Count() << endl; }
type::reverse_iterators
type::const_reverse_iterators
rbegin(var)
, or var.rbegin()
crbegin(var)
, or var.crbegin()
rend(var)
, or var.rend()
crend(var)
, or cvar.rend()
#include<algorithm>
find(beginning iterator, ending iterator, item)
sort(beginning iterator, end iterator)