// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // array.h -- // // Author : Richard C. Bilson // Created On : Wed May 27 17:56:53 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Wed Mar 2 18:13:35 2016 // Update Count : 5 // #ifndef ARRAY_H #define ARRAY_H //#include // An array has contiguous elements accessible in any order using integer indicies. The first // element has index 0. trait array( otype array_type, otype elt_type ) { lvalue elt_type ?[?]( array_type, int ); }; // A bounded array is an array that carries its maximum index with it. trait bounded_array( otype array_type, otype elt_type | array( array_type, elt_type ) ) { int last( array_type ); }; // implement iterator_for typedef int array_iterator; /// forall( otype array_type, elt_type | bounded_array( array_type, elt_type ) ) /// [ array_iterator begin, array_iterator end ] get_iterators( array_type ); // A bounded array can be iterated over by using a pointer to the element type. These functions // return iterators corresponding to the first element and the one-past-the-end element, STL-style. forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) elt_type *begin( array_type ); forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) ) elt_type *end( array_type ); #endif // ARRAY_H // Local Variables: // // tab-width: 4 // // compile-command: "cfa array.c" // // End: //