137 NodeElement * IndexTable;
161 NodeElement
const * Archive;
170 bool Increase_Table_Size(
int amount);
175 bool Is_Archive_Same(
int id)
const;
180 void Invalidate_Archive(
void);
185 void Set_Archive(NodeElement
const * node);
190 NodeElement
const * Search_For_Node(
int id)
const;
192 static int _USERENTRY search_compfunc(
void const * ptr,
void const * ptr2);
218 Invalidate_Archive();
261 delete [] IndexTable;
266 Invalidate_Archive();
287bool IndexClass<T>::Increase_Table_Size(
int amount)
292 if (amount < 0)
return(
false);
294 NodeElement * table =
W3DNEWARRAY NodeElement[IndexSize + amount];
300 for (
int index = 0; index < IndexCount; index++) {
301 table[index] = IndexTable[index];
307 delete [] IndexTable;
310 Invalidate_Archive();
371 if (IndexCount == 0) {
380 if (Is_Archive_Same(
id)) {
388 NodeElement
const * nodeptr = Search_For_Node(
id);
433 return(Archive->Data);
459bool IndexClass<T>::Is_Archive_Same(
int id)
const
461 if (Archive != 0 && Archive->ID ==
id) {
485void IndexClass<T>::Invalidate_Archive(
void)
507void IndexClass<T>::Set_Archive(NodeElement
const * node)
540 if (IndexCount + 1 > IndexSize) {
541 if (!Increase_Table_Size(IndexSize == 0 ? 10 : IndexSize)) {
554 IndexTable[IndexCount].ID = id;
555 IndexTable[IndexCount].Data = data;
584 int found_index = -1;
585 for (
int index = 0; index < IndexCount; index++) {
586 if (IndexTable[index].ID ==
id) {
598 if (found_index != -1) {
600 for (
int index = found_index+1; index < IndexCount; index++) {
601 IndexTable[index-1] = IndexTable[index];
608 IndexTable[IndexCount] = fake;
610 Invalidate_Archive();
636int _USERENTRY IndexClass<T>::search_compfunc(
void const * ptr1,
void const * ptr2)
638 if (*(
int const *)ptr1 == *(
int const *)ptr2) {
641 if (*(
int const *)ptr1 < *(
int const *)ptr2) {
666NodeElement
const * IndexClass<T>::Search_For_Node(
int id)
const
668IndexClass<T>::NodeElement
const * IndexClass<T>::Search_For_Node(
int id)
const
674 if (IndexCount == 0) {
683 qsort(&IndexTable[0], IndexCount,
sizeof(IndexTable[0]), search_compfunc);
693 return((NodeElement
const *)bsearch(&node, &IndexTable[0], IndexCount,
sizeof(IndexTable[0]), search_compfunc));