2 docCopyright("Steve Dekorte", 2002)
3 docLicense("BSD revised")
5 Stack - array of void pointers
6 supports setting marks - when a mark is popped,
7 all stack items above it are popped as well
9 Designed to optimize push, pushMark and popMark
10 at the expense of pop (since pop requires a mark check)
15 #define STACK_DEFINED 1
28 #ifdef LOW_MEMORY_SYSTEM
29 #define STACK_START_SIZE 512
30 #define STACK_RESIZE_FACTOR 2
32 #define STACK_START_SIZE 512
33 #define STACK_RESIZE_FACTOR 2
36 typedef void (StackDoCallback
)(void *);
37 typedef void (StackDoOnCallback
)(void *, void *);
39 //#define STACK_POP_CALLBACK
41 #ifdef STACK_POP_CALLBACK
42 typedef void (StackPopCallback
)(void *);
52 #ifdef STACK_POP_CALLBACK
53 StackPopCallback
*popCallback
;
57 #define Stack_popCallback_(self, callback) self->popCallback = callback;
59 BASEKIT_API Stack
*Stack_new(void);
60 BASEKIT_API
void Stack_free(Stack
*self
);
61 BASEKIT_API Stack
*Stack_clone(const Stack
*self
);
62 BASEKIT_API
void Stack_copy_(Stack
*self
, const Stack
*other
);
64 BASEKIT_API
size_t Stack_memorySize(const Stack
*self
);
65 BASEKIT_API
void Stack_compact(Stack
*self
);
67 BASEKIT_API
void Stack_resize(Stack
*self
);
69 BASEKIT_API
void Stack_popToMark_(Stack
*self
, intptr_t mark
);
71 // not high performance
73 BASEKIT_API
void Stack_makeMarksNull(Stack
*self
);
74 BASEKIT_API Stack
*Stack_newCopyWithNullMarks(const Stack
*self
);
75 BASEKIT_API
void Stack_do_on_(const Stack
*self
, StackDoOnCallback
*callback
, void *target
);
77 BASEKIT_API List
*Stack_asList(const Stack
*self
);
79 #include "Stack_inline.h"