Qt 4.8
Public Functions | Properties | List of all members
QDataBuffer< Type > Class Template Reference

#include <qdatabuffer_p.h>

Public Functions

void add (const Type &t)
 
Typeat (int i)
 
const Typeat (int i) const
 
Typedata () const
 
Typefirst ()
 
const Typefirst () const
 
bool isEmpty () const
 
Typelast ()
 
const Typelast () const
 
QDataBufferoperator<< (const Type &t)
 
void pop_back ()
 
 QDataBuffer (int res)
 
void reserve (int size)
 
void reset ()
 
void resize (int size)
 
void shrink (int size)
 
int size () const
 
void swap (QDataBuffer< Type > &other)
 
 ~QDataBuffer ()
 

Properties

Typebuffer
 
int capacity
 
int siz
 

Detailed Description

template<typename Type>
class QDataBuffer< Type >

Definition at line 60 of file qdatabuffer_p.h.

Constructors and Destructors

◆ QDataBuffer()

template<typename Type>
QDataBuffer< Type >::QDataBuffer ( int  res)
inline

Definition at line 63 of file qdatabuffer_p.h.

64  {
65  capacity = res;
66  if (res)
67  buffer = (Type*) qMalloc(capacity * sizeof(Type));
68  else
69  buffer = 0;
70  siz = 0;
71  }
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53

◆ ~QDataBuffer()

template<typename Type>
QDataBuffer< Type >::~QDataBuffer ( )
inline

Definition at line 73 of file qdatabuffer_p.h.

74  {
75  if (buffer)
76  qFree(buffer);
77  }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58

Functions

◆ add()

template<typename Type>
void QDataBuffer< Type >::add ( const Type t)
inline

◆ at() [1/2]

template<typename Type>
Type& QDataBuffer< Type >::at ( int  i)
inline

◆ at() [2/2]

template<typename Type>
const Type& QDataBuffer< Type >::at ( int  i) const
inline

Definition at line 87 of file qdatabuffer_p.h.

87 { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ data()

template<typename Type>
Type* QDataBuffer< Type >::data ( ) const
inline

◆ first() [1/2]

template<typename Type>
Type& QDataBuffer< Type >::first ( )
inline

Definition at line 90 of file qdatabuffer_p.h.

90 { Q_ASSERT(!isEmpty()); return buffer[0]; }
bool isEmpty() const
Definition: qdatabuffer_p.h:81
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ first() [2/2]

template<typename Type>
const Type& QDataBuffer< Type >::first ( ) const
inline

Definition at line 91 of file qdatabuffer_p.h.

91 { Q_ASSERT(!isEmpty()); return buffer[0]; }
bool isEmpty() const
Definition: qdatabuffer_p.h:81
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ isEmpty()

template<typename Type>
bool QDataBuffer< Type >::isEmpty ( ) const
inline

◆ last() [1/2]

template<typename Type>
Type& QDataBuffer< Type >::last ( )
inline

Definition at line 88 of file qdatabuffer_p.h.

Referenced by QGL2PEXVertexArray::addClosingLine(), QWingedEdge::insert(), and QTriangulator< T >::SimpleToMonotone::monotoneDecomposition().

88 { Q_ASSERT(!isEmpty()); return buffer[siz-1]; }
bool isEmpty() const
Definition: qdatabuffer_p.h:81
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ last() [2/2]

template<typename Type>
const Type& QDataBuffer< Type >::last ( ) const
inline

Definition at line 89 of file qdatabuffer_p.h.

89 { Q_ASSERT(!isEmpty()); return buffer[siz-1]; }
bool isEmpty() const
Definition: qdatabuffer_p.h:81
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ operator<<()

template<typename Type>
QDataBuffer& QDataBuffer< Type >::operator<< ( const Type t)
inline

Definition at line 135 of file qdatabuffer_p.h.

135 { add(t); return *this; }
void add(const Type &t)
Definition: qdatabuffer_p.h:93

◆ pop_back()

template<typename Type>
void QDataBuffer< Type >::pop_back ( )
inline

Definition at line 99 of file qdatabuffer_p.h.

99  {
100  Q_ASSERT(siz > 0);
101  --siz;
102  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ reserve()

template<typename Type>
void QDataBuffer< Type >::reserve ( int  size)
inline

Definition at line 109 of file qdatabuffer_p.h.

Referenced by QDataBuffer< GLfloat >::add(), QDashedStrokeProcessor::process(), and QDataBuffer< GLfloat >::resize().

109  {
110  if (size > capacity) {
111  if (capacity == 0)
112  capacity = 1;
113  while (capacity < size)
114  capacity *= 2;
115  buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type));
116  }
117  }
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63
int size() const
Definition: qdatabuffer_p.h:83

◆ reset()

template<typename Type>
void QDataBuffer< Type >::reset ( )
inline

◆ resize()

template<typename Type>
void QDataBuffer< Type >::resize ( int  size)
inline

◆ shrink()

template<typename Type>
void QDataBuffer< Type >::shrink ( int  size)
inline

Definition at line 119 of file qdatabuffer_p.h.

119  {
120  capacity = size;
121  if (size)
122  buffer = (Type*) qRealloc(buffer, capacity * sizeof(Type));
123  else {
124  qFree(buffer);
125  buffer = 0;
126  }
127  }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63
int size() const
Definition: qdatabuffer_p.h:83

◆ size()

template<typename Type>
int QDataBuffer< Type >::size ( ) const
inline

◆ swap()

template<typename Type>
void QDataBuffer< Type >::swap ( QDataBuffer< Type > &  other)
inline

Definition at line 129 of file qdatabuffer_p.h.

129  {
130  qSwap(capacity, other.capacity);
131  qSwap(siz, other.siz);
132  qSwap(buffer, other.buffer);
133  }
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181

Properties

◆ buffer

template<typename Type>
Type* QDataBuffer< Type >::buffer
private

◆ capacity

template<typename Type>
int QDataBuffer< Type >::capacity
private

◆ siz

template<typename Type>
int QDataBuffer< Type >::siz
private

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