Created
April 25, 2016 19:58
-
-
Save PeterZhizhin/6d857b9ad32cb0b314d2b04730e9b6c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
friend class iterator; | |
class iterator : | |
public std::iterator<std::forward_iterator_tag, pair_t> { | |
private: | |
std::list<size_t>::iterator lit; | |
typename std::vector<Element>::iterator it; | |
public: | |
iterator(HashMap& h, std::list<size_t>::iterator _lit) : | |
lit(_lit), it(h.elements.begin()) {} | |
iterator(HashMap& h, size_t position) : | |
iterator(h, h.elements[position].it) {} | |
bool operator==(const iterator& other) const { | |
return (it == other.it) && (lit == other.lit); | |
} | |
bool operator!=(const iterator& other) const { | |
return !(*this == other); | |
} | |
pair_t& operator*() { | |
return (it + *lit)->pair; | |
} | |
pair_t* operator->() { | |
return &(operator*()); | |
} | |
iterator& operator++() { | |
++lit; | |
return *this; | |
} | |
iterator operator++(int) { | |
iterator tmp(*this); | |
operator++(); | |
return tmp; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Код Element: