ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
ctor
deferred_resn
demangler
enum
forall-pointer-decay
gc_noraii
jacob/cs343-translation
jenkins-sandbox
memory
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
string
with_gc
Last change
on this file since 53a2e97 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago |
licencing: seventh groups of files
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[51b73452] | 1 | #ifndef ARRAY_H
|
---|
| 2 | #define ARRAY_H
|
---|
| 3 |
|
---|
[134b86a] | 4 | //#include "iterator.h"
|
---|
[51b73452] | 5 |
|
---|
[134b86a] | 6 | // An array has contiguous elements accessible in any order using integer indicies. The first
|
---|
| 7 | // element has index 0.
|
---|
| 8 | context array( type array_type, type elt_type ) {
|
---|
| 9 | lvalue elt_type ?[?]( array_type, int );
|
---|
[51b73452] | 10 | };
|
---|
| 11 |
|
---|
[134b86a] | 12 | // A bounded array is an array that carries its maximum index with it.
|
---|
| 13 | context bounded_array( type array_type, type elt_type | array( array_type, elt_type ) ) {
|
---|
| 14 | int last( array_type );
|
---|
[51b73452] | 15 | };
|
---|
| 16 |
|
---|
| 17 | // implement iterator_for
|
---|
| 18 |
|
---|
| 19 | typedef int array_iterator;
|
---|
[134b86a] | 20 |
|
---|
[51b73452] | 21 | /// forall( type array_type, elt_type | bounded_array( array_type, elt_type ) )
|
---|
| 22 | /// [ array_iterator begin, array_iterator end ] get_iterators( array_type );
|
---|
[134b86a] | 23 |
|
---|
| 24 |
|
---|
| 25 | // A bounded array can be iterated over by using a pointer to the element type. These functions
|
---|
| 26 | // return iterators corresponding to the first element and the one-past-the-end element, STL-style.
|
---|
[51b73452] | 27 | forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
|
---|
[134b86a] | 28 | elt_type *begin( array_type );
|
---|
| 29 |
|
---|
[51b73452] | 30 | forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
|
---|
[134b86a] | 31 | elt_type *end( array_type );
|
---|
[51b73452] | 32 |
|
---|
[134b86a] | 33 | #endif // ARRAY_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.