source: src/libcfa/iterator@ 6182039

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 6182039 was bb82c03, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Removed #ifdef for CFORALL in libcfa headers

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[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
[4040425]12// Last Modified On : Wed Mar 2 18:06:05 2016
13// Update Count : 9
[86bd7c1f]14//
15
[51b73452]16#ifndef ITERATOR_H
17#define ITERATOR_H
18
[134b86a]19// An iterator can be used to traverse a data structure.
[4040425]20trait iterator( otype iterator_type, otype elt_type ) {
[86bd7c1f]21 // point to the next element
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
31 lvalue elt_type *?( iterator_type );
[51b73452]32};
33
[4040425]34trait iterator_for( otype iterator_type, otype collection_type, otype elt_type | iterator( iterator_type, elt_type ) ) {
[86bd7c1f]35// [ iterator_type begin, iterator_type end ] get_iterators( collection_type );
36 iterator_type begin( collection_type );
37 iterator_type end( collection_type );
[51b73452]38};
39
[4040425]40forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
[51b73452]41void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
42
[4040425]43forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
[e56cfdb0]44void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
[134b86a]45
46#endif // ITERATOR_H
[86bd7c1f]47
48// Local Variables: //
[d3b7937]49// mode: c //
[86bd7c1f]50// tab-width: 4 //
51// End: //
Note: See TracBrowser for help on using the repository browser.