34#ifndef _WDL_PTRLIST_H_
35#define _WDL_PTRLIST_H_
53 PTRTYPE **list = (PTRTYPE**)
m_hb.Get();
58 int GetSize(
void)
const {
return m_hb.GetSize()/(
unsigned int)
sizeof(PTRTYPE *); }
60 int Find(
const PTRTYPE *
p)
const
64 PTRTYPE **list=(PTRTYPE **)
m_hb.Get();
67 for (
x = 0;
x <
n;
x ++)
if (list[
x] ==
p)
return x;
75 PTRTYPE **list=(PTRTYPE **)
m_hb.Get();
77 while (--
x >= 0)
if (list[
x] ==
p)
return x;
82 PTRTYPE *
Add(PTRTYPE *item)
85 PTRTYPE **list=(PTRTYPE **)
m_hb.ResizeOK((
s+1)*(
unsigned int)
sizeof(PTRTYPE*),
false);
94 PTRTYPE *
Set(
int index, PTRTYPE *item)
96 PTRTYPE **list=(PTRTYPE **)
m_hb.Get();
97 if (list && index >= 0 && index <
GetSize())
return list[index]=item;
101 PTRTYPE *
Insert(
int index, PTRTYPE *item)
104 PTRTYPE **list = (PTRTYPE **)
m_hb.ResizeOK((
s+1)*(
unsigned int)
sizeof(PTRTYPE*),
false);
106 if (!list)
return item;
108 if (index<0) index=0;
111 for (
x =
s;
x > index;
x --) list[
x]=list[
x-1];
112 return (list[
x] = item);
114 int FindSorted(
const PTRTYPE *
p,
int (*compar)(
const PTRTYPE **
a,
const PTRTYPE **
b))
const
120 PTRTYPE *
InsertSorted(PTRTYPE *item,
int (*compar)(
const PTRTYPE **
a,
const PTRTYPE **
b))
130 if (list && index >= 0 && index <
size)
132 if (index < --
size) memmove(list+index,list+index+1,(
unsigned int)
sizeof(PTRTYPE *)*(
size-index));
133 m_hb.Resize(
size * (
unsigned int)
sizeof(PTRTYPE*),
false);
136 void Delete(
int index,
bool wantDelete,
void (*delfunc)(
void *)=
NULL)
140 if (list && index >= 0 && index <
size)
144 if (delfunc) delfunc(
Get(index));
145 else delete Get(index);
147 if (index < --
size) memmove(list+index,list+index+1,(
unsigned int)
sizeof(PTRTYPE *)*(
size-index));
148 m_hb.Resize(
size * (
unsigned int)
sizeof(PTRTYPE*),
false);
151 void Delete(
int index,
void (*delfunc)(PTRTYPE *))
155 if (list && index >= 0 && index <
size)
157 if (delfunc) delfunc(
Get(index));
158 if (index < --
size) memmove(list+index,list+index+1,(
unsigned int)
sizeof(PTRTYPE *)*(
size-index));
159 m_hb.Resize(
size * (
unsigned int)
sizeof(PTRTYPE*),
false);
168 m_hb.Resize(0,
false);
170 void Empty(
bool wantDelete,
void (*delfunc)(
void *)=
NULL)
180 if (delfunc) delfunc(
p);
183 m_hb.Resize(
x*(
unsigned int)
sizeof(PTRTYPE *),
false);
186 m_hb.Resize(0,
false);
188 void Empty(
void (*delfunc)(PTRTYPE *))
194 if (delfunc &&
p) delfunc(
p);
195 m_hb.Resize(
x*(
unsigned int)
sizeof(PTRTYPE *),
false);
200 if (!wantDelete)
Empty();
207 tmp.
Empty(
true,delfunc);
211 int LowerBound(
const PTRTYPE *
key,
bool* ismatch,
int (*compar)(
const PTRTYPE **
a,
const PTRTYPE **
b))
const
219 int cmp = compar((
const PTRTYPE **)&
key, (
const PTRTYPE **)(list+
b));
220 if (cmp > 0)
a =
b+1;
221 else if (cmp < 0)
c =
b;
239 PTRTYPE **rd =
GetList(), **wr = rd;
240 for (
int x = 0;
x < sz;
x ++)
244 if (rd != wr) *wr=*rd;
250 if (cnt < sz)
m_hb.Resize(cnt *
sizeof(PTRTYPE*),
false);
uint8_t a
Definition Spc_Cpu.h:141
~WDL_PtrList_DeleteOnDestroy()
Definition ptrlist.h:264
void(* m_delfunc)(void *)
Definition ptrlist.h:269
WDL_PtrList_DeleteOnDestroy(void(*delfunc)(void *)=NULL, int defgran=4096)
Definition ptrlist.h:263
PTRTYPE * InsertSorted(PTRTYPE *item, int(*compar)(const PTRTYPE **a, const PTRTYPE **b))
Definition ptrlist.h:120
void Compact()
Definition ptrlist.h:232
int LowerBound(const PTRTYPE *key, bool *ismatch, int(*compar)(const PTRTYPE **a, const PTRTYPE **b)) const
Definition ptrlist.h:211
PTRTYPE * Add(PTRTYPE *item)
Definition ptrlist.h:82
void DeletePtr(const PTRTYPE *p, void(*delfunc)(PTRTYPE *))
Definition ptrlist.h:164
int DeleteBatch(bool(*proc)(PTRTYPE *p, void *ctx), void *ctx=NULL)
Definition ptrlist.h:235
WDL_HeapBuf m_hb
Definition ptrlist.h:255
void Empty(bool wantDelete, void(*delfunc)(void *)=NULL)
Definition ptrlist.h:170
PTRTYPE * Insert(int index, PTRTYPE *item)
Definition ptrlist.h:101
void Delete(int index, bool wantDelete, void(*delfunc)(void *)=NULL)
Definition ptrlist.h:136
PTRTYPE * Get(INT_PTR index) const
Definition ptrlist.h:51
void EmptySafe(bool wantDelete=false, void(*delfunc)(void *)=NULL)
Definition ptrlist.h:198
void Delete(int index, void(*delfunc)(PTRTYPE *))
Definition ptrlist.h:151
PTRTYPE ** GetList() const
Definition ptrlist.h:50
PTRTYPE * Set(int index, PTRTYPE *item)
Definition ptrlist.h:94
WDL_PtrList(int defgran=4096)
Definition ptrlist.h:42
int FindR(const PTRTYPE *p) const
Definition ptrlist.h:71
int Find(const PTRTYPE *p) const
Definition ptrlist.h:60
void Empty()
Definition ptrlist.h:166
int FindSorted(const PTRTYPE *p, int(*compar)(const PTRTYPE **a, const PTRTYPE **b)) const
Definition ptrlist.h:114
void Delete(int index)
Definition ptrlist.h:126
void DeletePtr(const PTRTYPE *p, bool wantDelete, void(*delfunc)(void *)=NULL)
Definition ptrlist.h:163
void Empty(void(*delfunc)(PTRTYPE *))
Definition ptrlist.h:188
~WDL_PtrList()
Definition ptrlist.h:46
int GetSize(void) const
Definition ptrlist.h:58
void DeletePtr(const PTRTYPE *p)
Definition ptrlist.h:162
unsigned * m
Definition inflate.c:1559
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned x[BMAX+1]
Definition inflate.c:1586
#define WDL_HEAPBUF_TRACEPARM(x)
Definition heapbuf.h:42
uintptr_t UINT_PTR
Definition swell-types.h:43
intptr_t INT_PTR
Definition swell-types.h:42
int n
Definition crypt.c:458
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
ZCONST char * key
Definition crypt.c:587
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396