Split arraddn into pointer and index return
This commit is contained in:
parent
e423b41e74
commit
e485c7d353
15
stb_ds.h
15
stb_ds.h
@ -108,11 +108,16 @@ DOCUMENTATION
|
|||||||
Inserts n uninitialized items into array a starting at a[p],
|
Inserts n uninitialized items into array a starting at a[p],
|
||||||
moving the rest of the array over.
|
moving the rest of the array over.
|
||||||
|
|
||||||
arraddn:
|
arraddnptr:
|
||||||
T* arraddn(T* a, int n)
|
T* arraddnptr(T* a, int n)
|
||||||
Appends n uninitialized items onto array at the end.
|
Appends n uninitialized items onto array at the end.
|
||||||
Returns a pointer to the first uninitialized item added.
|
Returns a pointer to the first uninitialized item added.
|
||||||
|
|
||||||
|
arraddnoff:
|
||||||
|
size_t arraddnoff(T* a, int n)
|
||||||
|
Appends n uninitialized items onto array at the end.
|
||||||
|
Returns the index of the first uninitialized item added.
|
||||||
|
|
||||||
arrdel:
|
arrdel:
|
||||||
void arrdel(T* a, int p);
|
void arrdel(T* a, int p);
|
||||||
Deletes the element at a[p], moving the rest of the array over.
|
Deletes the element at a[p], moving the rest of the array over.
|
||||||
@ -390,7 +395,8 @@ CREDITS
|
|||||||
#define arrpush stbds_arrput
|
#define arrpush stbds_arrput
|
||||||
#define arrpop stbds_arrpop
|
#define arrpop stbds_arrpop
|
||||||
#define arrfree stbds_arrfree
|
#define arrfree stbds_arrfree
|
||||||
#define arraddn stbds_arraddn
|
#define arraddnptr stbds_arraddnptr
|
||||||
|
#define arraddnoff stbds_arraddnoff
|
||||||
#define arrsetlen stbds_arrsetlen
|
#define arrsetlen stbds_arrsetlen
|
||||||
#define arrlast stbds_arrlast
|
#define arrlast stbds_arrlast
|
||||||
#define arrins stbds_arrins
|
#define arrins stbds_arrins
|
||||||
@ -522,7 +528,8 @@ extern void * stbds_shmode_func(size_t elemsize, int mode);
|
|||||||
#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))
|
#define stbds_arrput(a,v) (stbds_arrmaybegrow(a,1), (a)[stbds_header(a)->length++] = (v))
|
||||||
#define stbds_arrpush stbds_arrput // synonym
|
#define stbds_arrpush stbds_arrput // synonym
|
||||||
#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])
|
#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])
|
||||||
#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])
|
#define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)])
|
||||||
|
#define stbds_arraddnoff(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n))
|
||||||
#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])
|
#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])
|
||||||
#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)
|
#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL)
|
||||||
#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)
|
#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)
|
||||||
|
Loading…
Reference in New Issue
Block a user