21 if (busy ())
return -1;
31 if (
flag) out <<
", ";
55 : h (
h2), i (0), l (
h2->a[0]) {}
60 if (i >= h->n)
return;
62 if ((++i) >= h->n)
return;
77 ASSERT (busy (),
"end of iterator");
86 ASSERT (busy (),
"end of iterator");
105template <
class T,
class U>
120template <
class T,
class U>
122 : h (
h2), i (0), l (
h2->a[0]) {}
124template <
class T,
class U>
127 if (i >= h->n)
return;
129 if ((++i) >= h->n)
return;
134template <
class T,
class U>
141template <
class T,
class U>
144 ASSERT (busy (),
"end of iterator");
150template <
class T,
class U>
153 ASSERT (busy (),
"end of iterator");
158template <
class T,
class U>
164template <
class T,
class U>
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
bool busy()
Returns whether the iterator has another element.
hashmap_iterator_rep(hashmap< T, U > h)
void increase()
Increase the iterator.
T next()
Returns the current element of the iterator, and move the iterator forward.
T current()
Returns the current element of the iterator.
list< hashentry< T, U > > l
void increase()
Increase the iterator.
bool busy()
Returns whether the iterator has another element.
hashset_iterator_rep(hashset< T > h)
T next()
Returns the current element of the iterator, and move the iterator forward.
T current()
Returns the current element of the iterator.
An abstract base class for iterator implementation.
virtual int remains()
Returns the number of elements remaining in the iterator.
The list class represents a linked list.
iterator< T > iterate(hashset< T > h)
Generates an iterator for a container of type hashset<T>.
tm_ostream & operator<<(tm_ostream &out, iterator< T > it)
Outputs the iterator object to an output stream.
bool is_nil(list< T > l)
Check if a list is nil (i.e., an empty list).