| [86bd7c1f] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
| [bb82c03] | 7 | // iterator -- | 
|---|
| [86bd7c1f] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Wed May 27 17:56:53 2015 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [8a97248] | 12 | // Last Modified On : Thu Feb  2 11:21:50 2023 | 
|---|
|  | 13 | // Update Count     : 11 | 
|---|
| [86bd7c1f] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [53a6c2a] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [134b86a] | 18 | // An iterator can be used to traverse a data structure. | 
|---|
| [8a97248] | 19 | forall( iterator_type, elt_type ) | 
|---|
|  | 20 | trait iterator { | 
|---|
| [86bd7c1f] | 21 | // point to the next element | 
|---|
| [a493682] | 22 | //      iterator_type ?++( iterator_type & ); | 
|---|
|  | 23 | iterator_type ++?( iterator_type & ); | 
|---|
|  | 24 | iterator_type --?( iterator_type & ); | 
|---|
| [134b86a] | 25 |  | 
|---|
| [86bd7c1f] | 26 | // can be tested for equality with other iterators | 
|---|
|  | 27 | int ?==?( iterator_type, iterator_type ); | 
|---|
|  | 28 | int ?!=?( iterator_type, iterator_type ); | 
|---|
| [134b86a] | 29 |  | 
|---|
| [86bd7c1f] | 30 | // dereference to get the pointed-at element | 
|---|
| [533804b] | 31 | elt_type & *?( iterator_type ); | 
|---|
| [51b73452] | 32 | }; | 
|---|
|  | 33 |  | 
|---|
| [8a97248] | 34 | forall( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) | 
|---|
|  | 35 | trait iterator_for { | 
|---|
| [86bd7c1f] | 36 | //      [ iterator_type begin, iterator_type end ] get_iterators( collection_type ); | 
|---|
|  | 37 | iterator_type begin( collection_type ); | 
|---|
|  | 38 | iterator_type end( collection_type ); | 
|---|
| [51b73452] | 39 | }; | 
|---|
|  | 40 |  | 
|---|
| [fd54fef] | 41 | forall( iterator_type, elt_type | iterator( iterator_type, elt_type ) ) | 
|---|
| [53a6c2a] | 42 | void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ); | 
|---|
| [51b73452] | 43 |  | 
|---|
| [fd54fef] | 44 | forall( iterator_type, elt_type | iterator( iterator_type, elt_type ) ) | 
|---|
| [53a6c2a] | 45 | void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ); | 
|---|
| [86bd7c1f] | 46 |  | 
|---|
|  | 47 | // Local Variables: // | 
|---|
| [d3b7937] | 48 | // mode: c // | 
|---|
| [86bd7c1f] | 49 | // tab-width: 4 // | 
|---|
|  | 50 | // End: // | 
|---|