Ignore:
Timestamp:
Nov 3, 2014, 4:38:08 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
8c17ab0
Parents:
93885663
Message:

add compiler flag to driver, update examples, fix unnamed bit fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/examples/vector_int.h

    r93885663 r134b86a  
    22#define VECTOR_INT_H
    33
    4 typedef struct vector_int
    5 {
    6   int last;
    7   int capacity;
    8   int *data;
     4// A flexible array, similar to a C++ vector, that holds integers and can be resized dynamically
     5
     6typedef struct vector_int {
     7    int last;                                           // last used index
     8    int capacity;                                       // last possible index before reallocation
     9    int *data;                                          // array
    910} vector_int;
    1011
     12vector_int vector_int_allocate();                       // allocate vector with default capacity
     13vector_int vector_int_allocate( int reserve );          // allocate vector with specified capacity
     14void vector_int_deallocate( vector_int );               // deallocate vector's storage
    1115
    12 vector_int vector_int_allocate();
    13 vector_int vector_int_allocate( int reserve );
    14 void vector_int_deallocate( vector_int );
    15 
    16 void reserve( vector_int *vec, int reserve );
    17 void append( vector_int *vec, int element );
     16void reserve( vector_int *vec, int reserve );           // reserve more capacity
     17void append( vector_int *vec, int element );            // add element to end of vector, resizing as necessary
    1818
    1919// implement bounded_array
    2020
    21 lvalue int ?[?]( vector_int vec, int index );
    22 int array_last( vector_int vec );
     21lvalue int ?[?]( vector_int vec, int index );           // access to arbitrary element (does not resize)
     22int last( vector_int vec );                             // return last element
    2323
    24 #endif /* #ifndef VECTOR_INT_H */
     24#endif // VECTOR_INT_H
Note: See TracChangeset for help on using the changeset viewer.