source: libcfa/src/iterator.hfa @ 716b62c

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 716b62c was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 4 years ago

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

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