33#ifndef SMALLCHANGE_SBLIST_H
34#define SMALLCHANGE_SBLIST_H
36#include <Inventor/SbBasic.h>
45 enum { DEFAULTSIZE = 4 };
57 void append(
const Type
item);
58 int find(
const Type
item)
const;
60 void remove(
const int index);
61 void removeFast(
const int index);
64 void removeItem(
const Type
item);
66 int getLength(
void)
const;
67 void truncate(
const int length,
const int fit = 0);
69 void push(
const Type
item);
74 const Type * getArrayPtr(
const int start = 0)
const;
76 Type operator[](
const int index)
const;
77 Type & operator[](
const int index);
85 void expand(
const int size);
86 int getArraySize(
void)
const;
89 void grow(
const int size = -1);
94 Type builtinbuffer[DEFAULTSIZE];
100template <
class Type>
inline
102 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer)
107template <
class Type>
inline
109 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer)
114template <
class Type>
inline
117 if (this->itembuffer != builtinbuffer)
delete [] this->itembuffer;
122template <
class Type>
inline void
126 if (size == -1) this->itembuffersize <<= 1;
128 else { this->itembuffersize = size; }
130 Type *
newbuffer =
new Type[this->itembuffersize];
131 const int n = this->numitems;
133 if (this->itembuffer != this->builtinbuffer)
delete [] this->itembuffer;
137template <
class Type>
inline void
141 this->numitems = size;
144template <
class Type>
inline int
147 return this->itembuffersize;
150template <
class Type>
inline void
153 if (
this == &
l)
return;
155 const int n =
l.numitems;
157 for (
int i = 0;
i < n;
i++) this->itembuffer[
i] =
l.itembuffer[
i];
167template <
class Type>
inline void
170 const int items = this->numitems;
180 if (this->itembuffer != this->builtinbuffer)
delete [] this->itembuffer;
182 this->itembuffersize = items > DEFAULTSIZE ? items : DEFAULTSIZE;
186template <
class Type>
inline void
189 if (this->numitems == this->itembuffersize) this->grow();
190 this->itembuffer[this->numitems++] =
item;
193template <
class Type>
inline int
196 for (
int i = 0;
i < this->numitems;
i++)
197 if (this->itembuffer[
i] ==
item)
return i;
201template <
class Type>
inline void
204#ifdef COIN_EXTRA_DEBUG
207 if (this->numitems == this->itembuffersize) this->grow();
210 this->itembuffer[
i] = this->itembuffer[
i-1];
215template <
class Type>
inline void
218 int idx = this->find(
item);
219#ifdef COIN_EXTRA_DEBUG
225template <
class Type>
inline void
228#ifdef COIN_EXTRA_DEBUG
232 for (
int i = index;
i < this->numitems;
i++)
233 this->itembuffer[
i] = this->itembuffer[
i + 1];
236template <
class Type>
inline void
239#ifdef COIN_EXTRA_DEBUG
242 this->itembuffer[index] = this->itembuffer[--this->numitems];
245template <
class Type>
inline int
248 return this->numitems;
251template <
class Type>
inline void
254#ifdef COIN_EXTRA_DEBUG
257 this->numitems = length;
258 if (fit) this->fit();
261template <
class Type>
inline void
267template <
class Type>
inline Type
270#ifdef COIN_EXTRA_DEBUG
271 assert(this->numitems > 0);
273 return this->itembuffer[--this->numitems];
276template <
class Type>
inline const Type *
279 return &this->itembuffer[
start];
282template <
class Type>
inline Type
285#ifdef COIN_EXTRA_DEBUG
288 return this->itembuffer[index];
291template <
class Type>
inline Type &
294#ifdef COIN_EXTRA_DEBUG
297 return this->itembuffer[index];
300template <
class Type>
inline int
303 if (
this == &
l)
return TRUE;
304 if (this->numitems !=
l.numitems)
return FALSE;
305 for (
int i = 0;
i < this->numitems;
i++)
306 if (this->itembuffer[
i] !=
l.itembuffer[
i])
return FALSE;
310template <
class Type>
inline int
313 return !(*
this ==
l);
Definition misc/SbList.h:69