doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __LIST_H__
30 #define __LIST_H__
31 
32 /*
33 ===============================================================================
34 
35  List template
36  Does not allocate memory until the first item is added.
37 
38 ===============================================================================
39 */
40 
41 
42 /*
43 ================
44 idListSortCompare<type>
45 ================
46 */
47 #ifdef __INTEL_COMPILER
48 // the intel compiler doesn't do the right thing here
49 template< class type >
50 ID_INLINE int idListSortCompare( const type *a, const type *b ) {
51  assert( 0 );
52  return 0;
53 }
54 #else
55 template< class type >
56 ID_INLINE int idListSortCompare( const type *a, const type *b ) {
57  return *a - *b;
58 }
59 #endif
60 
61 /*
62 ================
63 idListNewElement<type>
64 ================
65 */
66 template< class type >
67 ID_INLINE type *idListNewElement( void ) {
68  return new type;
69 }
70 
71 /*
72 ================
73 idSwap<type>
74 ================
75 */
76 template< class type >
77 ID_INLINE void idSwap( type &a, type &b ) {
78  type c = a;
79  a = b;
80  b = c;
81 }
82 
83 template< class type >
84 class idList {
85 public:
86 
87  typedef int cmp_t( const type *, const type * );
88  typedef type new_t( void );
89 
90  idList( int newgranularity = 16 );
91  idList( const idList<type> &other );
92  ~idList<type>( void );
93 
94  void Clear( void ); // clear the list
95  int Num( void ) const; // returns number of elements in list
96  int NumAllocated( void ) const; // returns number of elements allocated for
97  void SetGranularity( int newgranularity ); // set new granularity
98  int GetGranularity( void ) const; // get the current granularity
99 
100  size_t Allocated( void ) const; // returns total size of allocated memory
101  size_t Size( void ) const; // returns total size of allocated memory including size of list type
102  size_t MemoryUsed( void ) const; // returns size of the used elements in the list
103 
104  idList<type> & operator=( const idList<type> &other );
105  const type & operator[]( int index ) const;
106  type & operator[]( int index );
107 
108  void Condense( void ); // resizes list to exactly the number of elements it contains
109  void Resize( int newsize ); // resizes list to the given number of elements
110  void Resize( int newsize, int newgranularity ); // resizes list and sets new granularity
111  void SetNum( int newnum, bool resize = true ); // set number of elements in list and resize to exactly this number if necessary
112  void AssureSize( int newSize); // assure list has given number of elements, but leave them uninitialized
113  void AssureSize( int newSize, const type &initValue ); // assure list has given number of elements and initialize any new elements
114  void AssureSizeAlloc( int newSize, new_t *allocator ); // assure the pointer list has the given number of elements and allocate any new elements
115 
116  type * Ptr( void ); // returns a pointer to the list
117  const type * Ptr( void ) const; // returns a pointer to the list
118  type & Alloc( void ); // returns reference to a new data element at the end of the list
119  int Append( const type & obj ); // append element
120  int Append( const idList<type> &other ); // append list
121  int AddUnique( const type & obj ); // add unique element
122  int Insert( const type & obj, int index = 0 ); // insert the element at the given index
123  int FindIndex( const type & obj ) const; // find the index for the given element
124  type * Find( type const & obj ) const; // find pointer to the given element
125  int FindNull( void ) const; // find the index for the first NULL pointer in the list
126  int IndexOf( const type *obj ) const; // returns the index for the pointer to an element in the list
127  bool RemoveIndex( int index ); // remove the element at the given index
128  bool Remove( const type & obj ); // remove the element
129  void Sort( cmp_t *compare = ( cmp_t * )&idListSortCompare<type> );
130  void SortSubSection( int startIndex, int endIndex, cmp_t *compare = ( cmp_t * )&idListSortCompare<type> );
131  void Swap( idList<type> &other ); // swap the contents of the lists
132  void DeleteContents( bool clear ); // delete the contents of the list
133 
134 private:
135  int num;
136  int size;
139 };
140 
141 /*
142 ================
143 idList<type>::idList( int )
144 ================
145 */
146 template< class type >
147 ID_INLINE idList<type>::idList( int newgranularity ) {
148  assert( newgranularity > 0 );
149 
150  list = NULL;
151  granularity = newgranularity;
152  Clear();
153 }
154 
155 /*
156 ================
157 idList<type>::idList( const idList<type> &other )
158 ================
159 */
160 template< class type >
161 ID_INLINE idList<type>::idList( const idList<type> &other ) {
162  list = NULL;
163  *this = other;
164 }
165 
166 /*
167 ================
168 idList<type>::~idList<type>
169 ================
170 */
171 template< class type >
172 ID_INLINE idList<type>::~idList( void ) {
173  Clear();
174 }
175 
176 /*
177 ================
178 idList<type>::Clear
179 
180 Frees up the memory allocated by the list. Assumes that type automatically handles freeing up memory.
181 ================
182 */
183 template< class type >
184 ID_INLINE void idList<type>::Clear( void ) {
185  if ( list ) {
186  delete[] list;
187  }
188 
189  list = NULL;
190  num = 0;
191  size = 0;
192 }
193 
194 /*
195 ================
196 idList<type>::DeleteContents
197 
198 Calls the destructor of all elements in the list. Conditionally frees up memory used by the list.
199 Note that this only works on lists containing pointers to objects and will cause a compiler error
200 if called with non-pointers. Since the list was not responsible for allocating the object, it has
201 no information on whether the object still exists or not, so care must be taken to ensure that
202 the pointers are still valid when this function is called. Function will set all pointers in the
203 list to NULL.
204 ================
205 */
206 template< class type >
207 ID_INLINE void idList<type>::DeleteContents( bool clear ) {
208  int i;
209 
210  for( i = 0; i < num; i++ ) {
211  delete list[ i ];
212  list[ i ] = NULL;
213  }
214 
215  if ( clear ) {
216  Clear();
217  } else {
218  memset( list, 0, size * sizeof( type ) );
219  }
220 }
221 
222 /*
223 ================
224 idList<type>::Allocated
225 
226 return total memory allocated for the list in bytes, but doesn't take into account additional memory allocated by type
227 ================
228 */
229 template< class type >
230 ID_INLINE size_t idList<type>::Allocated( void ) const {
231  return size * sizeof( type );
232 }
233 
234 /*
235 ================
236 idList<type>::Size
237 
238 return total size of list in bytes, but doesn't take into account additional memory allocated by type
239 ================
240 */
241 template< class type >
242 ID_INLINE size_t idList<type>::Size( void ) const {
243  return sizeof( idList<type> ) + Allocated();
244 }
245 
246 /*
247 ================
248 idList<type>::MemoryUsed
249 ================
250 */
251 template< class type >
252 ID_INLINE size_t idList<type>::MemoryUsed( void ) const {
253  return num * sizeof( *list );
254 }
255 
256 /*
257 ================
258 idList<type>::Num
259 
260 Returns the number of elements currently contained in the list.
261 Note that this is NOT an indication of the memory allocated.
262 ================
263 */
264 template< class type >
265 ID_INLINE int idList<type>::Num( void ) const {
266  return num;
267 }
268 
269 /*
270 ================
271 idList<type>::NumAllocated
272 
273 Returns the number of elements currently allocated for.
274 ================
275 */
276 template< class type >
277 ID_INLINE int idList<type>::NumAllocated( void ) const {
278  return size;
279 }
280 
281 /*
282 ================
283 idList<type>::SetNum
284 
285 Resize to the exact size specified irregardless of granularity
286 ================
287 */
288 template< class type >
289 ID_INLINE void idList<type>::SetNum( int newnum, bool resize ) {
290  assert( newnum >= 0 );
291  if ( resize || newnum > size ) {
292  Resize( newnum );
293  }
294  num = newnum;
295 }
296 
297 /*
298 ================
299 idList<type>::SetGranularity
300 
301 Sets the base size of the array and resizes the array to match.
302 ================
303 */
304 template< class type >
305 ID_INLINE void idList<type>::SetGranularity( int newgranularity ) {
306  int newsize;
307 
308  assert( newgranularity > 0 );
309  granularity = newgranularity;
310 
311  if ( list ) {
312  // resize it to the closest level of granularity
313  newsize = num + granularity - 1;
314  newsize -= newsize % granularity;
315  if ( newsize != size ) {
316  Resize( newsize );
317  }
318  }
319 }
320 
321 /*
322 ================
323 idList<type>::GetGranularity
324 
325 Get the current granularity.
326 ================
327 */
328 template< class type >
329 ID_INLINE int idList<type>::GetGranularity( void ) const {
330  return granularity;
331 }
332 
333 /*
334 ================
335 idList<type>::Condense
336 
337 Resizes the array to exactly the number of elements it contains or frees up memory if empty.
338 ================
339 */
340 template< class type >
341 ID_INLINE void idList<type>::Condense( void ) {
342  if ( list ) {
343  if ( num ) {
344  Resize( num );
345  } else {
346  Clear();
347  }
348  }
349 }
350 
351 /*
352 ================
353 idList<type>::Resize
354 
355 Allocates memory for the amount of elements requested while keeping the contents intact.
356 Contents are copied using their = operator so that data is correnctly instantiated.
357 ================
358 */
359 template< class type >
360 ID_INLINE void idList<type>::Resize( int newsize ) {
361  type *temp;
362  int i;
363 
364  assert( newsize >= 0 );
365 
366  // free up the list if no data is being reserved
367  if ( newsize <= 0 ) {
368  Clear();
369  return;
370  }
371 
372  if ( newsize == size ) {
373  // not changing the size, so just exit
374  return;
375  }
376 
377  temp = list;
378  size = newsize;
379  if ( size < num ) {
380  num = size;
381  }
382 
383  // copy the old list into our new one
384  list = new type[ size ];
385  for( i = 0; i < num; i++ ) {
386  list[ i ] = temp[ i ];
387  }
388 
389  // delete the old list if it exists
390  if ( temp ) {
391  delete[] temp;
392  }
393 }
394 
395 /*
396 ================
397 idList<type>::Resize
398 
399 Allocates memory for the amount of elements requested while keeping the contents intact.
400 Contents are copied using their = operator so that data is correnctly instantiated.
401 ================
402 */
403 template< class type >
404 ID_INLINE void idList<type>::Resize( int newsize, int newgranularity ) {
405  type *temp;
406  int i;
407 
408  assert( newsize >= 0 );
409 
410  assert( newgranularity > 0 );
411  granularity = newgranularity;
412 
413  // free up the list if no data is being reserved
414  if ( newsize <= 0 ) {
415  Clear();
416  return;
417  }
418 
419  temp = list;
420  size = newsize;
421  if ( size < num ) {
422  num = size;
423  }
424 
425  // copy the old list into our new one
426  list = new type[ size ];
427  for( i = 0; i < num; i++ ) {
428  list[ i ] = temp[ i ];
429  }
430 
431  // delete the old list if it exists
432  if ( temp ) {
433  delete[] temp;
434  }
435 }
436 
437 /*
438 ================
439 idList<type>::AssureSize
440 
441 Makes sure the list has at least the given number of elements.
442 ================
443 */
444 template< class type >
445 ID_INLINE void idList<type>::AssureSize( int newSize ) {
446  int newNum = newSize;
447 
448  if ( newSize > size ) {
449 
450  if ( granularity == 0 ) { // this is a hack to fix our memset classes
451  granularity = 16;
452  }
453 
454  newSize += granularity - 1;
455  newSize -= newSize % granularity;
456  Resize( newSize );
457  }
458 
459  num = newNum;
460 }
461 
462 /*
463 ================
464 idList<type>::AssureSize
465 
466 Makes sure the list has at least the given number of elements and initialize any elements not yet initialized.
467 ================
468 */
469 template< class type >
470 ID_INLINE void idList<type>::AssureSize( int newSize, const type &initValue ) {
471  int newNum = newSize;
472 
473  if ( newSize > size ) {
474 
475  if ( granularity == 0 ) { // this is a hack to fix our memset classes
476  granularity = 16;
477  }
478 
479  newSize += granularity - 1;
480  newSize -= newSize % granularity;
481  num = size;
482  Resize( newSize );
483 
484  for ( int i = num; i < newSize; i++ ) {
485  list[i] = initValue;
486  }
487  }
488 
489  num = newNum;
490 }
491 
492 /*
493 ================
494 idList<type>::AssureSizeAlloc
495 
496 Makes sure the list has at least the given number of elements and allocates any elements using the allocator.
497 
498 NOTE: This function can only be called on lists containing pointers. Calling it
499 on non-pointer lists will cause a compiler error.
500 ================
501 */
502 template< class type >
503 ID_INLINE void idList<type>::AssureSizeAlloc( int newSize, new_t *allocator ) {
504  int newNum = newSize;
505 
506  if ( newSize > size ) {
507 
508  if ( granularity == 0 ) { // this is a hack to fix our memset classes
509  granularity = 16;
510  }
511 
512  newSize += granularity - 1;
513  newSize -= newSize % granularity;
514  num = size;
515  Resize( newSize );
516 
517  for ( int i = num; i < newSize; i++ ) {
518  list[i] = (*allocator)();
519  }
520  }
521 
522  num = newNum;
523 }
524 
525 /*
526 ================
527 idList<type>::operator=
528 
529 Copies the contents and size attributes of another list.
530 ================
531 */
532 template< class type >
534  int i;
535 
536  Clear();
537 
538  num = other.num;
539  size = other.size;
540  granularity = other.granularity;
541 
542  if ( size ) {
543  list = new type[ size ];
544  for( i = 0; i < num; i++ ) {
545  list[ i ] = other.list[ i ];
546  }
547  }
548 
549  return *this;
550 }
551 
552 /*
553 ================
554 idList<type>::operator[] const
555 
556 Access operator. Index must be within range or an assert will be issued in debug builds.
557 Release builds do no range checking.
558 ================
559 */
560 template< class type >
561 ID_INLINE const type &idList<type>::operator[]( int index ) const {
562  assert( index >= 0 );
563  assert( index < num );
564 
565  return list[ index ];
566 }
567 
568 /*
569 ================
570 idList<type>::operator[]
571 
572 Access operator. Index must be within range or an assert will be issued in debug builds.
573 Release builds do no range checking.
574 ================
575 */
576 template< class type >
578  assert( index >= 0 );
579  assert( index < num );
580 
581  return list[ index ];
582 }
583 
584 /*
585 ================
586 idList<type>::Ptr
587 
588 Returns a pointer to the begining of the array. Useful for iterating through the list in loops.
589 
590 Note: may return NULL if the list is empty.
591 
592 FIXME: Create an iterator template for this kind of thing.
593 ================
594 */
595 template< class type >
596 ID_INLINE type *idList<type>::Ptr( void ) {
597  return list;
598 }
599 
600 /*
601 ================
602 idList<type>::Ptr
603 
604 Returns a pointer to the begining of the array. Useful for iterating through the list in loops.
605 
606 Note: may return NULL if the list is empty.
607 
608 FIXME: Create an iterator template for this kind of thing.
609 ================
610 */
611 template< class type >
612 const ID_INLINE type *idList<type>::Ptr( void ) const {
613  return list;
614 }
615 
616 /*
617 ================
618 idList<type>::Alloc
619 
620 Returns a reference to a new data element at the end of the list.
621 ================
622 */
623 template< class type >
624 ID_INLINE type &idList<type>::Alloc( void ) {
625  if ( !list ) {
626  Resize( granularity );
627  }
628 
629  if ( num == size ) {
630  Resize( size + granularity );
631  }
632 
633  return list[ num++ ];
634 }
635 
636 /*
637 ================
638 idList<type>::Append
639 
640 Increases the size of the list by one element and copies the supplied data into it.
641 
642 Returns the index of the new element.
643 ================
644 */
645 template< class type >
646 ID_INLINE int idList<type>::Append( type const & obj ) {
647  if ( !list ) {
648  Resize( granularity );
649  }
650 
651  if ( num == size ) {
652  int newsize;
653 
654  if ( granularity == 0 ) { // this is a hack to fix our memset classes
655  granularity = 16;
656  }
657  newsize = size + granularity;
658  Resize( newsize - newsize % granularity );
659  }
660 
661  list[ num ] = obj;
662  num++;
663 
664  return num - 1;
665 }
666 
667 
668 /*
669 ================
670 idList<type>::Insert
671 
672 Increases the size of the list by at leat one element if necessary
673 and inserts the supplied data into it.
674 
675 Returns the index of the new element.
676 ================
677 */
678 template< class type >
679 ID_INLINE int idList<type>::Insert( type const & obj, int index ) {
680  if ( !list ) {
681  Resize( granularity );
682  }
683 
684  if ( num == size ) {
685  int newsize;
686 
687  if ( granularity == 0 ) { // this is a hack to fix our memset classes
688  granularity = 16;
689  }
690  newsize = size + granularity;
691  Resize( newsize - newsize % granularity );
692  }
693 
694  if ( index < 0 ) {
695  index = 0;
696  }
697  else if ( index > num ) {
698  index = num;
699  }
700  for ( int i = num; i > index; --i ) {
701  list[i] = list[i-1];
702  }
703  num++;
704  list[index] = obj;
705  return index;
706 }
707 
708 /*
709 ================
710 idList<type>::Append
711 
712 adds the other list to this one
713 
714 Returns the size of the new combined list
715 ================
716 */
717 template< class type >
718 ID_INLINE int idList<type>::Append( const idList<type> &other ) {
719  if ( !list ) {
720  if ( granularity == 0 ) { // this is a hack to fix our memset classes
721  granularity = 16;
722  }
723  Resize( granularity );
724  }
725 
726  int n = other.Num();
727  for (int i = 0; i < n; i++) {
728  Append(other[i]);
729  }
730 
731  return Num();
732 }
733 
734 /*
735 ================
736 idList<type>::AddUnique
737 
738 Adds the data to the list if it doesn't already exist. Returns the index of the data in the list.
739 ================
740 */
741 template< class type >
742 ID_INLINE int idList<type>::AddUnique( type const & obj ) {
743  int index;
744 
745  index = FindIndex( obj );
746  if ( index < 0 ) {
747  index = Append( obj );
748  }
749 
750  return index;
751 }
752 
753 /*
754 ================
755 idList<type>::FindIndex
756 
757 Searches for the specified data in the list and returns it's index. Returns -1 if the data is not found.
758 ================
759 */
760 template< class type >
761 ID_INLINE int idList<type>::FindIndex( type const & obj ) const {
762  int i;
763 
764  for( i = 0; i < num; i++ ) {
765  if ( list[ i ] == obj ) {
766  return i;
767  }
768  }
769 
770  // Not found
771  return -1;
772 }
773 
774 /*
775 ================
776 idList<type>::Find
777 
778 Searches for the specified data in the list and returns it's address. Returns NULL if the data is not found.
779 ================
780 */
781 template< class type >
782 ID_INLINE type *idList<type>::Find( type const & obj ) const {
783  int i;
784 
785  i = FindIndex( obj );
786  if ( i >= 0 ) {
787  return &list[ i ];
788  }
789 
790  return NULL;
791 }
792 
793 /*
794 ================
795 idList<type>::FindNull
796 
797 Searches for a NULL pointer in the list. Returns -1 if NULL is not found.
798 
799 NOTE: This function can only be called on lists containing pointers. Calling it
800 on non-pointer lists will cause a compiler error.
801 ================
802 */
803 template< class type >
804 ID_INLINE int idList<type>::FindNull( void ) const {
805  int i;
806 
807  for( i = 0; i < num; i++ ) {
808  if ( list[ i ] == NULL ) {
809  return i;
810  }
811  }
812 
813  // Not found
814  return -1;
815 }
816 
817 /*
818 ================
819 idList<type>::IndexOf
820 
821 Takes a pointer to an element in the list and returns the index of the element.
822 This is NOT a guarantee that the object is really in the list.
823 Function will assert in debug builds if pointer is outside the bounds of the list,
824 but remains silent in release builds.
825 ================
826 */
827 template< class type >
828 ID_INLINE int idList<type>::IndexOf( type const *objptr ) const {
829  int index;
830 
831  index = objptr - list;
832 
833  assert( index >= 0 );
834  assert( index < num );
835 
836  return index;
837 }
838 
839 /*
840 ================
841 idList<type>::RemoveIndex
842 
843 Removes the element at the specified index and moves all data following the element down to fill in the gap.
844 The number of elements in the list is reduced by one. Returns false if the index is outside the bounds of the list.
845 Note that the element is not destroyed, so any memory used by it may not be freed until the destruction of the list.
846 ================
847 */
848 template< class type >
849 ID_INLINE bool idList<type>::RemoveIndex( int index ) {
850  int i;
851 
852  assert( list != NULL );
853  assert( index >= 0 );
854  assert( index < num );
855 
856  if ( ( index < 0 ) || ( index >= num ) ) {
857  return false;
858  }
859 
860  num--;
861  for( i = index; i < num; i++ ) {
862  list[ i ] = list[ i + 1 ];
863  }
864 
865  return true;
866 }
867 
868 /*
869 ================
870 idList<type>::Remove
871 
872 Removes the element if it is found within the list and moves all data following the element down to fill in the gap.
873 The number of elements in the list is reduced by one. Returns false if the data is not found in the list. Note that
874 the element is not destroyed, so any memory used by it may not be freed until the destruction of the list.
875 ================
876 */
877 template< class type >
878 ID_INLINE bool idList<type>::Remove( type const & obj ) {
879  int index;
880 
881  index = FindIndex( obj );
882  if ( index >= 0 ) {
883  return RemoveIndex( index );
884  }
885 
886  return false;
887 }
888 
889 /*
890 ================
891 idList<type>::Sort
892 
893 Performs a qsort on the list using the supplied comparison function. Note that the data is merely moved around the
894 list, so any pointers to data within the list may no longer be valid.
895 ================
896 */
897 template< class type >
898 ID_INLINE void idList<type>::Sort( cmp_t *compare ) {
899  if ( !list ) {
900  return;
901  }
902  typedef int cmp_c(const void *, const void *);
903 
904  cmp_c *vCompare = (cmp_c *)compare;
905  qsort( ( void * )list, ( size_t )num, sizeof( type ), vCompare );
906 }
907 
908 /*
909 ================
910 idList<type>::SortSubSection
911 
912 Sorts a subsection of the list.
913 ================
914 */
915 template< class type >
916 ID_INLINE void idList<type>::SortSubSection( int startIndex, int endIndex, cmp_t *compare ) {
917  if ( !list ) {
918  return;
919  }
920  if ( startIndex < 0 ) {
921  startIndex = 0;
922  }
923  if ( endIndex >= num ) {
924  endIndex = num - 1;
925  }
926  if ( startIndex >= endIndex ) {
927  return;
928  }
929  typedef int cmp_c(const void *, const void *);
930 
931  cmp_c *vCompare = (cmp_c *)compare;
932  qsort( ( void * )( &list[startIndex] ), ( size_t )( endIndex - startIndex + 1 ), sizeof( type ), vCompare );
933 }
934 
935 /*
936 ================
937 idList<type>::Swap
938 
939 Swaps the contents of two lists
940 ================
941 */
942 template< class type >
943 ID_INLINE void idList<type>::Swap( idList<type> &other ) {
944  idSwap( num, other.num );
945  idSwap( size, other.size );
946  idSwap( granularity, other.granularity );
947  idSwap( list, other.list );
948 }
949 
950 #endif /* !__LIST_H__ */
void SortSubSection(int startIndex, int endIndex, cmp_t *compare=(cmp_t *)&idListSortCompare< type >)
Definition: List.h:916
assert(prefInfo.fullscreenBtn)
int granularity
Definition: List.h:137
idList< type > & operator=(const idList< type > &other)
Definition: List.h:533
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
void Swap(idList< type > &other)
Definition: List.h:943
void AssureSize(int newSize)
Definition: List.h:445
GLenum GLsizei n
Definition: glext.h:3705
int GetGranularity(void) const
Definition: List.h:329
void SetGranularity(int newgranularity)
Definition: List.h:305
type * Ptr(void)
Definition: List.h:596
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
type * list
Definition: List.h:138
GLhandleARB obj
Definition: glext.h:3602
int i
Definition: process.py:33
GLuint GLuint num
Definition: glext.h:5390
void Sort(cmp_t *compare=(cmp_t *)&idListSortCompare< type >)
Definition: List.h:898
int cmp_t(const type *, const type *)
Definition: List.h:87
GLuint index
Definition: glext.h:3476
const GLubyte * c
Definition: glext.h:4677
type & Alloc(void)
Definition: List.h:624
ID_INLINE int idListSortCompare(const type *a, const type *b)
Definition: List.h:56
#define NULL
Definition: Lib.h:88
size_t Size(void) const
Definition: List.h:242
type * Find(type const &obj) const
Definition: List.h:782
size_t Allocated(void) const
Definition: List.h:230
void DeleteContents(bool clear)
Definition: List.h:207
~idList(void)
Definition: List.h:172
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
void AssureSizeAlloc(int newSize, new_t *allocator)
Definition: List.h:503
ID_INLINE void idSwap(type &a, type &b)
Definition: List.h:77
int size
Definition: List.h:136
GLubyte GLubyte b
Definition: glext.h:4662
int Insert(const type &obj, int index=0)
Definition: List.h:679
int Append(const type &obj)
Definition: List.h:646
int AddUnique(const type &obj)
Definition: List.h:742
int Num(void) const
Definition: List.h:265
int FindNull(void) const
Definition: List.h:804
bool RemoveIndex(int index)
Definition: List.h:849
GLsizeiptr size
Definition: glext.h:3112
type new_t(void)
Definition: List.h:88
void Condense(void)
Definition: List.h:341
int IndexOf(const type *obj) const
Definition: List.h:828
int NumAllocated(void) const
Definition: List.h:277
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
ID_INLINE type * idListNewElement(void)
Definition: List.h:67
int FindIndex(const type &obj) const
Definition: List.h:761
Definition: List.h:84
void Resize(int newsize)
Definition: List.h:360
idList(int newgranularity=16)
Definition: List.h:147
bool Remove(const type &obj)
Definition: List.h:878
const type & operator[](int index) const
Definition: List.h:561
int num
Definition: List.h:135
size_t MemoryUsed(void) const
Definition: List.h:252
void Clear(void)
Definition: List.h:184