Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Resizable< ITEM > Class Template Reference

#include <resizable.h>

Public Member Functions

 Resizable ()
 
 Resizable (const Resizable< ITEM > &c)
 
 ~Resizable ()
 
void assert_free (unsigned int n)
 
void push_back_nocheck (const ITEM &a)
 
void inc_num (unsigned int n)
 
void push_back (const ITEM &a)
 
void push_back3 (const ITEM aa[3])
 
void push_back (const ITEM &aa, const ITEM &bb, const ITEM &cc)
 
void push_backN (const ITEM *aa, const unsigned int N)
 
ITEM * begin ()
 
ITEM * end ()
 
void clear ()
 
ITEM & back ()
 
ITEM & pop_back ()
 
unsigned int size ()
 

Detailed Description

template<class ITEM>
class Resizable< ITEM >

Definition at line 3 of file resizable.h.

Constructor & Destructor Documentation

template<class ITEM>
Resizable< ITEM >::Resizable ( )
inline

Definition at line 8 of file resizable.h.

8  : Resizable()
9  {
10  num = 0;
11  alloc = 16;
12  q = (ITEM*) malloc( sizeof (ITEM)*16 );
13  }
template<class ITEM>
Resizable< ITEM >::Resizable ( const Resizable< ITEM > &  c)
inline

Definition at line 14 of file resizable.h.

15  {
16  num = c.num;
17  alloc = c.alloc;
18  q = (ITEM*) malloc( sizeof (ITEM)*alloc );
19  memcpy( q, c.q, sizeof (ITEM)*num );
20  }
template<class ITEM>
Resizable< ITEM >::~Resizable ( )
inline

Definition at line 21 of file resizable.h.

22  {
23  free( q );
24  q = NULL;
25  }

Member Function Documentation

template<class ITEM>
void Resizable< ITEM >::assert_free ( unsigned int  n)
inline

Definition at line 26 of file resizable.h.

27  {
28  while (n+num > alloc) {
29  alloc *= 2;
30  q = (ITEM*) realloc( q, sizeof (ITEM)*alloc );
31  }
32  }
template<class ITEM>
ITEM& Resizable< ITEM >::back ( )
inline

Definition at line 95 of file resizable.h.

96  {
97  return q[num-1];
98  }
template<class ITEM>
ITEM* Resizable< ITEM >::begin ( )
inline

Definition at line 83 of file resizable.h.

84  {
85  return q;
86  }
template<class ITEM>
void Resizable< ITEM >::clear ( void  )
inline

Definition at line 91 of file resizable.h.

Referenced by TextureIndex::Clear().

92  {
93  num = 0;
94  }
template<class ITEM>
ITEM* Resizable< ITEM >::end ( )
inline

Definition at line 87 of file resizable.h.

88  {
89  return q+num;
90  }
template<class ITEM>
void Resizable< ITEM >::inc_num ( unsigned int  n)
inline

Definition at line 38 of file resizable.h.

39  {
40  num += n;
41  }
template<class ITEM>
ITEM& Resizable< ITEM >::pop_back ( )
inline

Definition at line 99 of file resizable.h.

100  {
101  num--;
102  return q[num];
103  }
template<class ITEM>
void Resizable< ITEM >::push_back ( const ITEM &  a)
inline

Definition at line 42 of file resizable.h.

43  {
44  if (alloc < num+1) {
45  alloc *= 2;
46  q = (ITEM*) realloc( q, sizeof (ITEM)*alloc );
47  }
48  q[num] = a;
49  num++;
50  }
template<class ITEM>
void Resizable< ITEM >::push_back ( const ITEM &  aa,
const ITEM &  bb,
const ITEM &  cc 
)
inline

Definition at line 62 of file resizable.h.

63  {
64  if (alloc < num+3) {
65  alloc *= 2;
66  q = (ITEM*) realloc( q, sizeof (ITEM)*alloc );
67  }
68  q[num] = aa;
69  q[num+1] = bb;
70  q[num+2] = cc;
71  num += 3;
72  }
template<class ITEM>
void Resizable< ITEM >::push_back3 ( const ITEM  aa[3])
inline

Definition at line 51 of file resizable.h.

52  {
53  if (alloc < num+3) {
54  alloc *= 2;
55  q = (ITEM*) realloc( q, sizeof (ITEM)*alloc );
56  }
57  q[num] = aa[0];
58  q[num+1] = aa[1];
59  q[num+2] = aa[2];
60  num += 3;
61  }
template<class ITEM>
void Resizable< ITEM >::push_back_nocheck ( const ITEM &  a)
inline

Definition at line 33 of file resizable.h.

34  {
35  q[num] = a;
36  num++;
37  }
template<class ITEM>
void Resizable< ITEM >::push_backN ( const ITEM *  aa,
const unsigned int  N 
)
inline

Definition at line 73 of file resizable.h.

74  {
75  while (alloc < num+N) {
76  alloc *= 2;
77  q = (ITEM*) realloc( q, sizeof (ITEM)*alloc );
78  }
79  for (unsigned int i = 0; i < N; i++)
80  q[num+i] = aa[i];
81  num += N;
82  }
template<class ITEM>
unsigned int Resizable< ITEM >::size ( void  )
inline

Definition at line 104 of file resizable.h.

105  {
106  return num;
107  }

The documentation for this class was generated from the following file: