source: src/libcfa/iterator @ 9d7b3ea

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 9d7b3ea was d3b7937, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

building runtime library (first attempt)

  • Property mode set to 100644
File size: 1.6 KB
Line 
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//
7// iterator --
8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Jan 27 23:49:13 2016
13// Update Count     : 7
14//
15
16#ifndef ITERATOR_H
17#define ITERATOR_H
18
19// An iterator can be used to traverse a data structure.
20context iterator( type iterator_type, type elt_type ) {
21        // point to the next element
22//      iterator_type ?++( iterator_type * );
23        iterator_type ++?( iterator_type * );
24        iterator_type --?( iterator_type * );
25
26        // can be tested for equality with other iterators
27        int ?==?( iterator_type, iterator_type );
28        int ?!=?( iterator_type, iterator_type );
29
30        // dereference to get the pointed-at element
31        lvalue elt_type *?( iterator_type );
32};
33
34context iterator_for( type iterator_type, type collection_type, type elt_type | iterator( iterator_type, elt_type ) ) {
35//      [ iterator_type begin, iterator_type end ] get_iterators( collection_type );
36        iterator_type begin( collection_type );
37        iterator_type end( collection_type );
38};
39
40forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
41void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
42
43forall( type iterator_type, type elt_type | iterator( iterator_type, elt_type ) )
44void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
45
46#endif // ITERATOR_H
47
48// Local Variables: //
49// mode: c //
50// tab-width: 4 //
51// End: //
Note: See TracBrowser for help on using the repository browser.