21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <string.h>
#ifdef __GNUC__
# include <new>
#else
# include <new.h>
#endif
#ifdef NULL
# undef NULL
#endif
#define NULL 0
typedef unsigned char uchar;
typedef unsigned short ushort;
|
>
>
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <string.h>
#ifdef __GNUC__
# include <new>
#else
# include <new.h>
#endif
#import <ObjFW/ObjFW.h>
#ifdef NULL
# undef NULL
#endif
#define NULL 0
typedef unsigned char uchar;
typedef unsigned short ushort;
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
T *buf;
int alen;
int ulen;
vector()
{
alen = 8;
buf = (T *)malloc(alen * sizeof(T));
ulen = 0;
}
~vector()
{
setsize(0);
free(buf);
|
|
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
T *buf;
int alen;
int ulen;
vector()
{
alen = 8;
buf = (T *)OFAllocMemory(alen, sizeof(T));
ulen = 0;
}
~vector()
{
setsize(0);
free(buf);
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
qsort(buf, ulen, sizeof(T),
(int(__cdecl *)(const void *, const void *))cf);
}
void
realloc()
{
buf = (T *)::realloc(buf, (alen *= 2) * sizeof(T));
}
T
remove(int i)
{
T e = buf[i];
for (int p = i + 1; p < ulen; p++)
|
|
|
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
qsort(buf, ulen, sizeof(T),
(int(__cdecl *)(const void *, const void *))cf);
}
void
realloc()
{
buf = (T *)OFResizeMemory(buf, (alen *= 2), sizeof(T));
}
T
remove(int i)
{
T e = buf[i];
for (int p = i + 1; p < ulen; p++)
|