Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QPODVector< T, Increment > Class Template Reference

#include <qpodvector_p.h>

Public Functions

void append (const T &v)
 
const T & at (int idx) const
 
void clear ()
 
bool contains (const T &v)
 
void copyAndClear (QPODVector< T, Increment > &other)
 
int count () const
 
int find (const T &v)
 
void insert (int idx, const T &v)
 
void insertBlank (int idx, int count)
 
QPODVector< T, Increment > & operator<< (const T &v)
 
T & operator[] (int idx)
 
void prepend (const T &v)
 
 QPODVector ()
 
void remove (int idx, int count=1)
 
void removeOne (const T &v)
 
void reserve (int count)
 
 ~QPODVector ()
 

Private Functions

QPODVectoroperator= (const QPODVector &)
 
 QPODVector (const QPODVector &)
 

Properties

int m_capacity
 
int m_count
 
T * m_data
 

Detailed Description

template<class T, int Increment = 1024>
class QPODVector< T, Increment >

Definition at line 62 of file qpodvector_p.h.

Constructors and Destructors

◆ QPODVector() [1/2]

template<class T, int Increment = 1024>
QPODVector< T, Increment >::QPODVector ( )
inline

◆ ~QPODVector()

template<class T, int Increment = 1024>
QPODVector< T, Increment >::~QPODVector ( )
inline

Definition at line 67 of file qpodvector_p.h.

67 { if (m_data) ::free(m_data); }

◆ QPODVector() [2/2]

template<class T, int Increment = 1024>
QPODVector< T, Increment >::QPODVector ( const QPODVector< T, Increment > &  )
private

Functions

◆ append()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::append ( const T &  v)
inline

Definition at line 85 of file qpodvector_p.h.

Referenced by QDeclarativeGrid::doPositioning(), and QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 >::operator<<().

85  {
86  insert(m_count, v);
87  }
void insert(int idx, const T &v)
Definition: qpodvector_p.h:89

◆ at()

template<class T, int Increment = 1024>
const T& QPODVector< T, Increment >::at ( int  idx) const
inline

◆ clear()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::clear ( )
inline

Definition at line 77 of file qpodvector_p.h.

77  {
78  m_count = 0;
79  }

◆ contains()

template<class T, int Increment = 1024>
bool QPODVector< T, Increment >::contains ( const T &  v)
inline

Definition at line 144 of file qpodvector_p.h.

144  {
145  return find(v) != -1;
146  }
int find(const T &v)
Definition: qpodvector_p.h:137

◆ copyAndClear()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::copyAndClear ( QPODVector< T, Increment > &  other)
inline

Definition at line 152 of file qpodvector_p.h.

Referenced by QDeclarativeQtScriptExpression::scriptValue().

152  {
153  if (other.m_data) ::free(other.m_data);
154  other.m_count = m_count;
155  other.m_capacity = m_capacity;
156  other.m_data = m_data;
157  m_count = 0;
158  m_capacity = 0;
159  m_data = 0;
160  }

◆ count()

template<class T, int Increment = 1024>
int QPODVector< T, Increment >::count ( ) const
inline

◆ find()

template<class T, int Increment = 1024>
int QPODVector< T, Increment >::find ( const T &  v)
inline

Definition at line 137 of file qpodvector_p.h.

Referenced by QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 >::contains().

137  {
138  for (int idx = 0; idx < m_count; ++idx)
139  if (m_data[idx] == v)
140  return idx;
141  return -1;
142  }

◆ insert()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::insert ( int  idx,
const T &  v 
)
inline

Definition at line 89 of file qpodvector_p.h.

Referenced by QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 >::append(), and QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 >::prepend().

89  {
90  if (m_count == m_capacity) {
91  m_capacity += Increment;
92  m_data = (T *)q_check_ptr(realloc(m_data, m_capacity * sizeof(T)));
93  }
94  int moveCount = m_count - idx;
95  if (moveCount)
96  ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T));
97  m_count++;
98  m_data[idx] = v;
99  }
T * q_check_ptr(T *p)
Definition: qglobal.h:1857

◆ insertBlank()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::insertBlank ( int  idx,
int  count 
)
inline

Definition at line 108 of file qpodvector_p.h.

108  {
109  int newSize = m_count + count;
110  reserve(newSize);
111  int moveCount = m_count - idx;
112  if (moveCount)
113  ::memmove(m_data + idx + count, m_data + idx,
114  moveCount * sizeof(T));
115  m_count = newSize;
116  }
int count() const
Definition: qpodvector_p.h:148
void reserve(int count)
Definition: qpodvector_p.h:101

◆ operator<<()

template<class T, int Increment = 1024>
QPODVector<T,Increment>& QPODVector< T, Increment >::operator<< ( const T &  v)
inline

Definition at line 162 of file qpodvector_p.h.

162 { append(v); return *this; }
void append(const T &v)
Definition: qpodvector_p.h:85

◆ operator=()

template<class T, int Increment = 1024>
QPODVector& QPODVector< T, Increment >::operator= ( const QPODVector< T, Increment > &  )
private

◆ operator[]()

template<class T, int Increment = 1024>
T& QPODVector< T, Increment >::operator[] ( int  idx)
inline

Definition at line 73 of file qpodvector_p.h.

73  {
74  return m_data[idx];
75  }

◆ prepend()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::prepend ( const T &  v)
inline

Definition at line 81 of file qpodvector_p.h.

81  {
82  insert(0, v);
83  }
void insert(int idx, const T &v)
Definition: qpodvector_p.h:89

◆ remove()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::remove ( int  idx,
int  count = 1 
)
inline

Definition at line 118 of file qpodvector_p.h.

118  {
119  int moveCount = m_count - (idx + count);
120  if (moveCount)
121  ::memmove(m_data + idx, m_data + idx + count,
122  moveCount * sizeof(T));
123  m_count -= count;
124  }
int count() const
Definition: qpodvector_p.h:148

◆ removeOne()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::removeOne ( const T &  v)
inline

Definition at line 126 of file qpodvector_p.h.

126  {
127  int idx = 0;
128  while (idx < m_count) {
129  if (m_data[idx] == v) {
130  remove(idx);
131  return;
132  }
133  ++idx;
134  }
135  }

◆ reserve()

template<class T, int Increment = 1024>
void QPODVector< T, Increment >::reserve ( int  count)
inline

Definition at line 101 of file qpodvector_p.h.

Referenced by QDeclarativeGrid::doPositioning(), and QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 >::insertBlank().

101  {
102  if (count >= m_capacity) {
103  m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1);
104  m_data = (T *)q_check_ptr(realloc(m_data, m_capacity * sizeof(T)));
105  }
106  }
T * q_check_ptr(T *p)
Definition: qglobal.h:1857
int count() const
Definition: qpodvector_p.h:148

Properties

◆ m_capacity

template<class T, int Increment = 1024>
int QPODVector< T, Increment >::m_capacity
private

◆ m_count

template<class T, int Increment = 1024>
int QPODVector< T, Increment >::m_count
private

◆ m_data

template<class T, int Increment = 1024>
T* QPODVector< T, Increment >::m_data
private

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