Lolly 1.4.28
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
hashmap_iterator_rep< T, U > Class Template Reference
Inheritance diagram for hashmap_iterator_rep< T, U >:
Inheritance graph
[legend]
Collaboration diagram for hashmap_iterator_rep< T, U >:
Collaboration graph
[legend]

Public Member Functions

 hashmap_iterator_rep (hashmap< T, U > h)
 
bool busy ()
 Returns whether the iterator has another element.
 
next ()
 Returns the current element of the iterator, and move the iterator forward.
 
current ()
 Returns the current element of the iterator.
 
void increase ()
 Increase the iterator.
 
- Public Member Functions inherited from iterator_rep< T >
 iterator_rep ()
 Constructor. Increments the iterator count.
 
virtual ~iterator_rep ()
 Destructor. Decrements the iterator count.
 
virtual int remains ()
 Returns the number of elements remaining in the iterator.
 
- Public Member Functions inherited from abstract_struct
 abstract_struct ()
 Default constructor for the abstract object. Sets the reference count to 0.
 
virtual ~abstract_struct ()
 Virtual destructor for the abstract object. Decrements the reference count.
 

Private Member Functions

void spool ()
 

Private Attributes

hashmap< T, U > h
 
int i
 
list< hashentry< T, U > > l
 

Additional Inherited Members

- Public Attributes inherited from abstract_struct
int ref_count
 The reference count for the abstract object.
 

Detailed Description

template<class T, class U>
class hashmap_iterator_rep< T, U >

Definition at line 106 of file iterator.ipp.

Constructor & Destructor Documentation

◆ hashmap_iterator_rep()

template<class T , class U >
hashmap_iterator_rep< T, U >::hashmap_iterator_rep ( hashmap< T, U > h)

Definition at line 121 of file iterator.ipp.

122 : h (h2), i (0), l (h2->a[0]) {}
list< hashentry< T, U > > l
Definition iterator.ipp:109
hashmap< T, U > h
Definition iterator.ipp:107
The list class represents a linked list.
Definition list.hpp:48

Member Function Documentation

◆ spool()

template<class T , class U >
void hashmap_iterator_rep< T, U >::spool ( )
private

Definition at line 126 of file iterator.ipp.

126 {
127 if (i >= h->n) return;
128 while (is_nil (l)) {
129 if ((++i) >= h->n) return;
130 l= h->a[i];
131 }
132}
bool is_nil(blackbox x)
Definition blackbox.hpp:29

◆ busy()

template<class T , class U >
bool hashmap_iterator_rep< T, U >::busy ( )
virtual

Returns whether the iterator has another element.

Returns
True if the iterator has another element, false otherwise.

Implements iterator_rep< T >.

Definition at line 136 of file iterator.ipp.

136 {
137 spool ();
138 return i < h->n;
139}

◆ next()

template<class T , class U >
T hashmap_iterator_rep< T, U >::next ( )
virtual

Returns the current element of the iterator, and move the iterator forward.

Returns
The current element of the iterator.

Implements iterator_rep< T >.

Definition at line 143 of file iterator.ipp.

143 {
144 ASSERT (busy (), "end of iterator");
145 T x (l->item.key);
146 l= l->next;
147 return x;
148}
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
Definition basic.hpp:85
bool busy()
Returns whether the iterator has another element.
Definition iterator.ipp:136

◆ current()

template<class T , class U >
T hashmap_iterator_rep< T, U >::current ( )
virtual

Returns the current element of the iterator.

Returns
The current element of the iterator.

Implements iterator_rep< T >.

Definition at line 152 of file iterator.ipp.

152 {
153 ASSERT (busy (), "end of iterator");
154 T x (l->item.key);
155 return x;
156}

◆ increase()

template<class T , class U >
void hashmap_iterator_rep< T, U >::increase ( )
virtual

Increase the iterator.

Implements iterator_rep< T >.

Definition at line 160 of file iterator.ipp.

160 {
161 l= l->next;
162}

Member Data Documentation

◆ h

template<class T , class U >
hashmap<T, U> hashmap_iterator_rep< T, U >::h
private

Definition at line 107 of file iterator.ipp.

◆ i

template<class T , class U >
int hashmap_iterator_rep< T, U >::i
private

Definition at line 108 of file iterator.ipp.

◆ l

template<class T , class U >
list<hashentry<T, U> > hashmap_iterator_rep< T, U >::l
private

Definition at line 109 of file iterator.ipp.


The documentation for this class was generated from the following files: