Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > DynArray
comparison DynArray.h @ 4:f35e64d7a42b
Working version used for probes in Master Env
| author | Me |
|---|---|
| date | Sat, 30 Oct 2010 22:12:32 -0700 |
| parents | 8473c52c6f0e |
| children | f4b108f21041 f9776626259b |
comparison
equal
deleted
inserted
replaced
| 1:b3bcd3fe65ec | 2:b0c04cf7f8d0 |
|---|---|
| 3 * Author: Me | 3 * Author: Me |
| 4 * | 4 * |
| 5 * Created on May 14, 2010, 3:08 PM | 5 * Created on May 14, 2010, 3:08 PM |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef _VECTOR_H | 8 #ifndef _DYNARRAY_H |
| 9 #define _VECTOR_H | 9 #define _DYNARRAY_H |
| 10 | 10 |
| 11 //Doing one special cheat -- hiding a back-ptr in front of array | 11 #include "../VMS_primitive_data_types.h" |
| 12 | |
| 13 | |
| 14 //A dynamic array is same as any other array, but add a DynArrayInfo next | |
| 15 // to it. Accesses and updates of array indexes are done normally, it's | |
| 16 // only when add a new element into array that use the extra info. | |
| 17 // An add can cause the pointer to the normal array to change.. so must | |
| 18 // be protected to single VP at a time. | |
| 12 typedef struct | 19 typedef struct |
| 13 { | 20 { |
| 14 void **arrayOfPtrs; | 21 void ***addrOfPtrToArray; //addr of array of ptrs == triple * |
| 15 int numPtrsInArray; | 22 int32 numInArray; |
| 16 int sizeOfArray; | 23 int32 sizeOfArray; |
| 17 } | 24 } |
| 18 Vector; | 25 DynArrayInfo; |
| 19 | 26 |
| 20 Vector *createVect ( int32 initialSizeOfArray ); | 27 DynArrayInfo * |
| 21 Vector *increaseSizeOfVect( Vector *vect ); | 28 makeDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); |
| 22 bool8 addToVect ( void *ptrToAdd, Vector *vect ); | 29 |
| 23 bool8 removeLastInVect ( Vector *vect ); | 30 DynArrayInfo * |
| 31 makeDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); | |
| 32 | |
| 33 int32 | |
| 34 addToDynArray( void *value, DynArrayInfo *info ); | |
| 35 | |
| 36 void | |
| 37 makeHighestDynArrayIndexBe( DynArrayInfo *info, int32 highestIndex ); | |
| 38 | |
| 39 void | |
| 40 increaseSizeOfDynArrayTo( DynArrayInfo *info, int32 newSize ); | |
| 41 | |
| 42 typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever | |
| 43 | |
| 44 void | |
| 45 freeDynArrayDeep( DynArrayInfo *info, FreeFnPtr freeFnPtr ); | |
| 46 | |
| 47 void | |
| 48 freeDynArrayFlat( DynArrayInfo *info ); | |
| 24 | 49 |
| 25 | 50 |
| 26 #endif /* _VECTOR_H */ | 51 typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * |
| 27 | 52 |
| 53 void | |
| 54 forAllInDynArrayDo( DynArrayInfo *info, DynArrayFnPtr fnPtr ); | |
| 55 | |
| 56 #endif /* _DYNARRAY_H */ | |
| 57 |
