29#include <Inventor/SbBasic.h>
56#pragma warning(disable:4251)
57#pragma warning(disable:4275)
65 enum { DEFAULTSIZE = 4 };
69 SbList(
const int sizehint = DEFAULTSIZE)
70 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer) {
71 if (sizehint > DEFAULTSIZE) this->grow(sizehint);
75 : itembuffersize(DEFAULTSIZE), numitems(0), itembuffer(builtinbuffer) {
80 if (this->itembuffer != builtinbuffer)
delete[] this->itembuffer;
84 if (
this == &l)
return;
85 const int n = l.numitems;
87 for (
int i = 0; i < n; i++) this->itembuffer[i] = l.itembuffer[i];
96 const int items = this->numitems;
106 if (this->itembuffer != this->builtinbuffer)
delete[] this->itembuffer;
108 this->itembuffersize = items > DEFAULTSIZE ? items : DEFAULTSIZE;
113 if (this->numitems == this->itembuffersize) this->grow();
114 this->itembuffer[this->numitems++] =
item;
118 for (
int i = 0;
i < this->numitems;
i++)
119 if (this->itembuffer[
i] ==
item)
return i;
124#ifdef COIN_EXTRA_DEBUG
127 if (this->numitems == this->itembuffersize) this->grow();
130 this->itembuffer[
i] = this->itembuffer[
i-1];
136 int idx = this->
find(item);
137#ifdef COIN_EXTRA_DEBUG
144#ifdef COIN_EXTRA_DEBUG
148 for (
int i = index;
i < this->numitems;
i++)
149 this->itembuffer[
i] = this->itembuffer[
i + 1];
153#ifdef COIN_EXTRA_DEBUG
156 this->itembuffer[index] = this->itembuffer[--this->numitems];
160 return this->numitems;
164#ifdef COIN_EXTRA_DEBUG
167 this->numitems = length;
176#ifdef COIN_EXTRA_DEBUG
177 assert(this->numitems > 0);
179 return this->itembuffer[--this->numitems];
183 return &this->itembuffer[start];
187#ifdef COIN_EXTRA_DEBUG
190 return this->itembuffer[index];
194#ifdef COIN_EXTRA_DEBUG
197 return this->itembuffer[index];
201 if (
this == &
l)
return TRUE;
202 if (this->numitems !=
l.numitems)
return FALSE;
203 for (
int i = 0;
i < this->numitems;
i++)
204 if (this->itembuffer[
i] !=
l.itembuffer[
i])
return FALSE;
209 return !(*
this ==
l);
213 if ((size > itembuffersize) &&
214 (size > DEFAULTSIZE)) {
223 this->numitems = size;
227 return this->itembuffersize;
231 void grow(
const int size = -1) {
233 if (size == -1) this->itembuffersize <<= 1;
235 else { this->itembuffersize = size; }
237 Type *
newbuffer =
new Type[this->itembuffersize];
238 const int n = this->numitems;
240 if (this->itembuffer != this->builtinbuffer)
delete[] this->itembuffer;
247 Type builtinbuffer[DEFAULTSIZE];
The SbList class is a template container class for lists.
Definition SbList.h:61
void truncate(const int length, const int dofit=0)
Definition SbList.h:163
int getLength(void) const
Definition SbList.h:159
SbList(const SbList< Type > &l)
Definition SbList.h:74
Type pop(void)
Definition SbList.h:175
int find(const Type item) const
Definition SbList.h:117
SbList< Type > & operator=(const SbList< Type > &l)
Definition SbList.h:90
void removeFast(const int index)
Definition SbList.h:152
Type & operator[](const int index)
Definition SbList.h:193
int operator!=(const SbList< Type > &l) const
Definition SbList.h:208
int getArraySize(void) const
Definition SbList.h:226
const Type * getArrayPtr(const int start=0) const
Definition SbList.h:182
void remove(const int index)
Definition SbList.h:143
SbList(const int sizehint=DEFAULTSIZE)
Definition SbList.h:69
void removeItem(const Type item)
Definition SbList.h:135
int operator==(const SbList< Type > &l) const
Definition SbList.h:200
void copy(const SbList< Type > &l)
Definition SbList.h:83
void fit(void)
Definition SbList.h:95
void insert(const Type item, const int insertbefore)
Definition SbList.h:123
~SbList()
Definition SbList.h:79
void append(const Type item)
Definition SbList.h:112
void expand(const int size)
Definition SbList.h:221
void ensureCapacity(const int size)
Definition SbList.h:212
Type operator[](const int index) const
Definition SbList.h:186
void push(const Type item)
Definition SbList.h:171