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

Public Member Functions

 hashset_iterator_rep (hashset< T > 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

hashset< T > h
 
int i
 
list< T > 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 hashset_iterator_rep< T >

Definition at line 39 of file iterator.ipp.

Constructor & Destructor Documentation

◆ hashset_iterator_rep()

Definition at line 54 of file iterator.ipp.

55 : h (h2), i (0), l (h2->a[0]) {}
The list class represents a linked list.
Definition list.hpp:48

Member Function Documentation

◆ spool()

template<class T >
void hashset_iterator_rep< T >::spool ( )
private

Definition at line 59 of file iterator.ipp.

59 {
60 if (i >= h->n) return;
61 while (is_nil (l)) {
62 if ((++i) >= h->n) return;
63 l= h->a[i];
64 }
65}
bool is_nil(blackbox x)
Definition blackbox.hpp:29

◆ busy()

template<class T >
bool hashset_iterator_rep< T >::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 69 of file iterator.ipp.

69 {
70 spool ();
71 return i < h->n;
72}

◆ next()

template<class T >
T hashset_iterator_rep< T >::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 76 of file iterator.ipp.

76 {
77 ASSERT (busy (), "end of iterator");
78 T x (l->item);
79 l= l->next;
80 return x;
81}
#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:69

◆ current()

template<class T >
T hashset_iterator_rep< T >::current ( )
virtual

Returns the current element of the iterator.

Returns
The current element of the iterator.

Implements iterator_rep< T >.

Definition at line 85 of file iterator.ipp.

85 {
86 ASSERT (busy (), "end of iterator");
87 T x (l->item);
88 return x;
89}

◆ increase()

template<class T >
void hashset_iterator_rep< T >::increase ( )
virtual

Increase the iterator.

Implements iterator_rep< T >.

Definition at line 93 of file iterator.ipp.

93 {
94 l= l->next;
95}

Member Data Documentation

◆ h

template<class T >
hashset<T> hashset_iterator_rep< T >::h
private

Definition at line 40 of file iterator.ipp.

◆ i

template<class T >
int hashset_iterator_rep< T >::i
private

Definition at line 41 of file iterator.ipp.

◆ l

template<class T >
list<T> hashset_iterator_rep< T >::l
private

Definition at line 42 of file iterator.ipp.


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