29#include <Inventor/SbBasic.h>
42#pragma warning(disable:4251)
43#pragma warning(disable:4275)
51 enum { DEFAULTSIZE = 4 };
55 SbList(
const int sizehint = DEFAULTSIZE)
56 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer) {
57 if (sizehint > DEFAULTSIZE) this->grow(sizehint);
61 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer) {
66 if (this->itembuffer != builtinbuffer)
delete[] this->itembuffer;
70 if (
this == &l)
return;
71 const int n = l.numitems;
73 for (
int i = 0; i < n; i++) this->itembuffer[i] = l.itembuffer[i];
82 const int items = this->numitems;
92 if (this->itembuffer != this->builtinbuffer)
delete[] this->itembuffer;
94 this->itembuffersize = items > DEFAULTSIZE ? items : DEFAULTSIZE;
99 if (this->numitems == this->itembuffersize) this->grow();
100 this->itembuffer[this->numitems++] =
item;
104 for (
int i = 0;
i < this->numitems;
i++)
105 if (this->itembuffer[
i] ==
item)
return i;
110#ifdef COIN_EXTRA_DEBUG
113 if (this->numitems == this->itembuffersize) this->grow();
116 this->itembuffer[
i] = this->itembuffer[
i-1];
122 int idx = this->
find(item);
123#ifdef COIN_EXTRA_DEBUG
130#ifdef COIN_EXTRA_DEBUG
134 for (
int i = index;
i < this->numitems;
i++)
135 this->itembuffer[
i] = this->itembuffer[
i + 1];
139#ifdef COIN_EXTRA_DEBUG
142 this->itembuffer[index] = this->itembuffer[--this->numitems];
146 return this->numitems;
150#ifdef COIN_EXTRA_DEBUG
153 this->numitems = length;
162#ifdef COIN_EXTRA_DEBUG
163 assert(this->numitems > 0);
165 return this->itembuffer[--this->numitems];
169 return &this->itembuffer[start];
173#ifdef COIN_EXTRA_DEBUG
176 return this->itembuffer[index];
180#ifdef COIN_EXTRA_DEBUG
183 return this->itembuffer[index];
187 if (
this == &
l)
return TRUE;
188 if (this->numitems !=
l.numitems)
return FALSE;
189 for (
int i = 0;
i < this->numitems;
i++)
190 if (this->itembuffer[
i] !=
l.itembuffer[
i])
return FALSE;
195 return !(*
this ==
l);
202 this->numitems = size;
206 return this->itembuffersize;
210 void grow(
const int size = -1) {
212 if (size == -1) this->itembuffersize <<= 1;
214 else { this->itembuffersize = size; }
216 Type *
newbuffer =
new Type[this->itembuffersize];
217 const int n = this->numitems;
219 if (this->itembuffer != this->builtinbuffer)
delete[] this->itembuffer;
226 Type builtinbuffer[DEFAULTSIZE];
The SbList class is a template container class for lists.
Definition SbList.h:47
void truncate(const int length, const int dofit=0)
Definition SbList.h:149
int getLength(void) const
Definition SbList.h:145
SbList(const SbList< Type > &l)
Definition SbList.h:60
Type pop(void)
Definition SbList.h:161
int find(const Type item) const
Definition SbList.h:103
SbList< Type > & operator=(const SbList< Type > &l)
Definition SbList.h:76
void removeFast(const int index)
Definition SbList.h:138
Type & operator[](const int index)
Definition SbList.h:179
int operator!=(const SbList< Type > &l) const
Definition SbList.h:194
int getArraySize(void) const
Definition SbList.h:205
const Type * getArrayPtr(const int start=0) const
Definition SbList.h:168
void remove(const int index)
Definition SbList.h:129
SbList(const int sizehint=DEFAULTSIZE)
Definition SbList.h:55
void removeItem(const Type item)
Definition SbList.h:121
int operator==(const SbList< Type > &l) const
Definition SbList.h:186
void copy(const SbList< Type > &l)
Definition SbList.h:69
void fit(void)
Definition SbList.h:81
void insert(const Type item, const int insertbefore)
Definition SbList.h:109
~SbList()
Definition SbList.h:65
void append(const Type item)
Definition SbList.h:98
void expand(const int size)
Definition SbList.h:200
Type operator[](const int index) const
Definition SbList.h:172
void push(const Type item)
Definition SbList.h:157