source: libcfa/src/iterator.hfa @ 04b73b6

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 04b73b6 was 73abe95, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Replace extension-less headers with .hfa

  • 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 : Fri Jul  7 08:37:25 2017
13// Update Count     : 10
14//
15
16#pragma once
17
18// An iterator can be used to traverse a data structure.
19trait iterator( otype iterator_type, otype elt_type ) {
20        // point to the next element
21//      iterator_type ?++( iterator_type & );
22        iterator_type ++?( iterator_type & );
23        iterator_type --?( iterator_type & );
24
25        // can be tested for equality with other iterators
26        int ?==?( iterator_type, iterator_type );
27        int ?!=?( iterator_type, iterator_type );
28
29        // dereference to get the pointed-at element
30        elt_type & *?( iterator_type );
31};
32
33trait iterator_for( otype iterator_type, otype collection_type, otype elt_type | iterator( iterator_type, elt_type ) ) {
34//      [ iterator_type begin, iterator_type end ] get_iterators( collection_type );
35        iterator_type begin( collection_type );
36        iterator_type end( collection_type );
37};
38
39forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
40void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
41
42forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
43void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
44
45// Local Variables: //
46// mode: c //
47// tab-width: 4 //
48// End: //
Note: See TracBrowser for help on using the repository browser.