44 struct Vector* newVector_(
int elSize,
int initSize,
char *,
int);
45 #define newVector(type, initSize) \
46 newVector_((int)sizeof(type), initSize,__FILE__,__LINE__)
48 #if defined(WRAP_MALLOC) || defined(DEBUG_MALLOC)
49 void deleteVectorDebug_(
char *file,
int line,
int elSize,
struct Vector**);
50 #define deleteVector(type, me) deleteVectorDebug_(__FILE__,__LINE__,(int)sizeof(type), &(me))
52 void deleteVector_(
int elSize,
struct Vector**);
53 #define deleteVector(type, me) deleteVector_((int)sizeof(type), ((struct Vector**)(&me)))
57 void vector_ensureSpace_(
int,
struct Vector*,
char *fi,
int line);
60 #define vector_get(type, me, ind) \
61 ((type*)((struct Vector*)me)->data)[ind]
64 #define vector_get_ptr(type, me, ind) \
65 &((type*)((struct Vector*)me)->data)[ind]
69 #define vector_set(type,me,element,value) \
70 ((type*)((struct Vector *) (me))->data)[element]=value
72 void vector_removeElement(
int elSize,
struct Vector* myp,
int element);
73 #define vector_remove_elem(type,me,element) \
74 vector_removeElement((int)sizeof(type),me,element)
77 #define vectorSize(me) \
78 (((struct Vector*)me)->n)
81 #define vector_back(type, me) \
82 vector_get(type, me, vectorSize(me)-1)
85 #define vector_empty(me) \
89 void vector_shrink_(
int,
struct Vector*);
90 #define vector_shrink(type, me) \
91 vector_shrink_((int)sizeof(type), me)
94 #define vector_pushBack(type, me, el) \
96 vector_ensureSpace_((int)sizeof(type), me,__FILE__,__LINE__); \
97 ASSERT(((struct Vector*)me)->n<((struct Vector*)me)->allocn); \
98 vector_get(type, me, ((struct Vector*)me)->n)=el; \
99 ++((struct Vector*)me)->n; \
103 void vector_popBack_(
struct Vector*,
size_t count);
104 #define vector_popBack(type, me) \
106 ASSERT(!vector_empty(me)); \
107 --((struct Vector*)me)->n; \
109 #define vector_popBackN(type, me, popn) \
111 ASSERT(popn<=vectorSize(me)); \
112 ((struct Vector*)me)->n-=popn; \
116 void* vector_releaseData_(
int,
struct Vector*);
117 #define vector_releaseData(type, me) \
118 vector_releaseData_((int)sizeof(type), me)
128 #define newStack(type) \
130 #define deleteStack(type, me) \
131 deleteVector(type, me)
134 #define stack_push(type, me, el) \
135 vector_pushBack(type, me, el)
136 #define stack_pop(type, me) \
137 vector_popBack(type, me)
140 #define stack_top(type, me) \
141 vector_get(type, me, vectorSize(me)-1)
144 #define stack_empty(me) \