QVector< T > Class Template Reference

QVector< T > Class Template Reference

#include <audiodataoutput.h>

Class Description

+ Inheritance diagram for QVector< T >:

Public Types

typedef T * iterator
 
typedef const T * const_iterator
 
typedef T value_type
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef qptrdiff difference_type
 
typedef iterator Iterator
 
typedef const_iterator ConstIterator
 
typedef int size_type
 

Public Member Functions

 QVector ()
 
 QVector (int size)
 
 QVector (int size, const T &t)
 
 QVector (const QVector< T > &v)
 
 ~QVector ()
 
QVector< T > & operator= (const QVector< T > &v)
 
void swap (QVector< T > &other)
 
bool operator== (const QVector< T > &v) const
 
bool operator!= (const QVector< T > &v) const
 
int size () const
 
bool isEmpty () const
 
void resize (int size)
 
int capacity () const
 
void reserve (int size)
 
void squeeze ()
 
void detach ()
 
bool isDetached () const
 
void setSharable (bool sharable)
 
bool isSharedWith (const QVector< T > &other) const
 
T * data ()
 
const T * data () const
 
const T * constData () const
 
void clear ()
 
const T & at (int i) const
 
T & operator[] (int i)
 
const T & operator[] (int i) const
 
void append (const T &t)
 
void prepend (const T &t)
 
void insert (int i, const T &t)
 
void insert (int i, int n, const T &t)
 
void replace (int i, const T &t)
 
void remove (int i)
 
void remove (int i, int n)
 
QVector< T > & fill (const T &t, int size=-1)
 
int indexOf (const T &t, int from=0) const
 
int lastIndexOf (const T &t, int from=-1) const
 
bool contains (const T &t) const
 
int count (const T &t) const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator constBegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator constEnd () const
 
iterator insert (iterator before, int n, const T &x)
 
iterator insert (iterator before, const T &x)
 
iterator erase (iterator begin, iterator end)
 
iterator erase (iterator pos)
 
int count () const
 
T & first ()
 
const T & first () const
 
T & last ()
 
const T & last () const
 
bool startsWith (const T &t) const
 
bool endsWith (const T &t) const
 
QVector< T > mid (int pos, int length=-1) const
 
value (int i) const
 
value (int i, const T &defaultValue) const
 
void push_back (const T &t)
 
void push_front (const T &t)
 
void pop_back ()
 
void pop_front ()
 
bool empty () const
 
T & front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
QVector< T > & operator+= (const QVector< T > &l)
 
QVector< T > operator+ (const QVector< T > &l) const
 
QVector< T > & operator+= (const T &t)
 
QVector< T > & operator<< (const T &t)
 
QVector< T > & operator<< (const QVector< T > &l)
 
QList< T > toList () const
 
std::vector< T > toStdVector () const
 

Static Public Member Functions

static QVector< T > fromList (const QList< T > &list)
 
static QVector< T > fromStdVector (const std::vector< T > &vector)
 

Friends

class QRegion
 

Member Typedef Documentation

typedef T* iterator

Definition at line 244 of file qvector.h.

typedef const T* const_iterator

Definition at line 245 of file qvector.h.

typedef T value_type

Definition at line 272 of file qvector.h.

typedef value_type* pointer

Definition at line 273 of file qvector.h.

typedef const value_type* const_pointer

Definition at line 274 of file qvector.h.

Definition at line 275 of file qvector.h.

typedef const value_type& const_reference

Definition at line 276 of file qvector.h.

typedef qptrdiff difference_type

Definition at line 277 of file qvector.h.

typedef iterator Iterator

Definition at line 278 of file qvector.h.

Definition at line 279 of file qvector.h.

typedef int size_type

Definition at line 280 of file qvector.h.

Constructor & Destructor Documentation

QVector ( )
inline

Definition at line 120 of file qvector.h.

120 : d(&QVectorData::shared_null) { d->ref.ref(); }
static QVectorData shared_null
Definition: qvector.h:82
QVectorData * d
Definition: qvector.h:109
QBasicAtomicInt ref
Definition: qvector.h:68
QVector ( int  size)
explicit

Definition at line 411 of file qvector.h.

412 {
413  d = malloc(asize);
414  d->ref = 1;
415  d->alloc = d->size = asize;
416  d->sharable = true;
417  d->capacity = false;
418  if (QTypeInfo<T>::isComplex) {
419  T* b = p->array;
420  T* i = p->array + d->size;
421  while (i != b)
422  new (--i) T;
423  } else {
424  qMemSet(p->array, 0, asize * sizeof(T));
425  }
426 }
uint capacity
Definition: qvector.h:78
uint sharable
Definition: qvector.h:77
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
int alloc
Definition: qvector.h:69
QBasicAtomicInt ref
Definition: qvector.h:68
QVector ( int  size,
const T &  t 
)

Definition at line 429 of file qvector.h.

430 {
431  d = malloc(asize);
432  d->ref = 1;
433  d->alloc = d->size = asize;
434  d->sharable = true;
435  d->capacity = false;
436  T* i = p->array + d->size;
437  while (i != p->array)
438  new (--i) T(t);
439 }
uint capacity
Definition: qvector.h:78
uint sharable
Definition: qvector.h:77
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
int alloc
Definition: qvector.h:69
GLdouble GLdouble t
Definition: GLee.h:1181
QBasicAtomicInt ref
Definition: qvector.h:68
QVector ( const QVector< T > &  v)
inline

Definition at line 123 of file qvector.h.

123 : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
uint sharable
Definition: qvector.h:77
QVectorData * d
Definition: qvector.h:109
QBasicAtomicInt ref
Definition: qvector.h:68
~QVector ( )
inline

Definition at line 124 of file qvector.h.

124 { if (!d) return; if (!d->ref.deref()) free(p); }
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
QBasicAtomicInt ref
Definition: qvector.h:68

Member Function Documentation

QVector< T > & operator= ( const QVector< T > &  v)

Definition at line 390 of file qvector.h.

391 {
392  QVectorData *o = v.d;
393  o->ref.ref();
394  if (!d->ref.deref())
395  free(p);
396  d = o;
397  if (!d->sharable)
398  detach_helper();
399  return *this;
400 }
uint sharable
Definition: qvector.h:77
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
QBasicAtomicInt ref
Definition: qvector.h:68
void swap ( QVector< T > &  other)
inline

Definition at line 130 of file qvector.h.

130 { qSwap(d, other.d); }
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
QVectorData * d
Definition: qvector.h:109
bool operator== ( const QVector< T > &  v) const

Definition at line 649 of file qvector.h.

650 {
651  if (d->size != v.d->size)
652  return false;
653  if (d == v.d)
654  return true;
655  T* b = p->array;
656  T* i = b + d->size;
657  T* j = v.p->array + d->size;
658  while (i != b)
659  if (!(*--i == *--j))
660  return false;
661  return true;
662 }
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
Data * p
Definition: qvector.h:113
bool operator!= ( const QVector< T > &  v) const
inline

Definition at line 135 of file qvector.h.

135 { return !(*this == v); }
const GLdouble * v
Definition: GLee.h:1174
int size ( ) const
inline

Definition at line 137 of file qvector.h.

137 { return d->size; }
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
bool isEmpty ( ) const
inline

Definition at line 139 of file qvector.h.

139 { return d->size == 0; }
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
void resize ( int  size)

Definition at line 342 of file qvector.h.

343 { realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize < (d->alloc >> 1))) ?
344  QVectorData::grow(sizeOfTypedData(), asize, sizeof(T), QTypeInfo<T>::isStatic)
345  : d->alloc); }
uint capacity
Definition: qvector.h:78
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
QVectorData * d
Definition: qvector.h:109
int alloc
Definition: qvector.h:69
GLsizeiptr size
Definition: GLee.h:1561
int capacity ( ) const
inline

Definition at line 143 of file qvector.h.

143 { return d->alloc; }
QVectorData * d
Definition: qvector.h:109
int alloc
Definition: qvector.h:69
void reserve ( int  size)

Definition at line 339 of file qvector.h.

340 { if (asize > d->alloc) realloc(d->size, asize); if (d->ref == 1) d->capacity = 1; }
uint capacity
Definition: qvector.h:78
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
int alloc
Definition: qvector.h:69
QBasicAtomicInt ref
Definition: qvector.h:68
void squeeze ( )
inline

Definition at line 145 of file qvector.h.

145 { realloc(d->size, d->size); d->capacity = 0; }
uint capacity
Definition: qvector.h:78
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
void detach ( )
inline

Definition at line 147 of file qvector.h.

147 { if (d->ref != 1) detach_helper(); }
QVectorData * d
Definition: qvector.h:109
QBasicAtomicInt ref
Definition: qvector.h:68
bool isDetached ( ) const
inline

Definition at line 148 of file qvector.h.

148 { return d->ref == 1; }
QVectorData * d
Definition: qvector.h:109
QBasicAtomicInt ref
Definition: qvector.h:68
void setSharable ( bool  sharable)
inline

Definition at line 149 of file qvector.h.

149 { if (!sharable) detach(); d->sharable = sharable; }
void detach()
Definition: qvector.h:147
uint sharable
Definition: qvector.h:77
QVectorData * d
Definition: qvector.h:109
bool isSharedWith ( const QVector< T > &  other) const
inline

Definition at line 150 of file qvector.h.

150 { return d == other.d; }
QVectorData * d
Definition: qvector.h:109
T* data ( )
inline

Definition at line 152 of file qvector.h.

152 { detach(); return p->array; }
void detach()
Definition: qvector.h:147
GLfloat GLfloat p
Definition: GLee.h:5416
const T* data ( ) const
inline

Definition at line 153 of file qvector.h.

153 { return p->array; }
GLfloat GLfloat p
Definition: GLee.h:5416
const T* constData ( ) const
inline

Definition at line 154 of file qvector.h.

154 { return p->array; }
GLfloat GLfloat p
Definition: GLee.h:5416
void clear ( )
inline

Definition at line 347 of file qvector.h.

348 { *this = QVector<T>(); }
const T & at ( int  i) const
inline

Definition at line 350 of file qvector.h.

351 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");
352  return p->array[i]; }
GLfloat GLfloat p
Definition: GLee.h:5416
GLsizeiptr size
Definition: GLee.h:1561
T & operator[] ( int  i)
inline

Definition at line 358 of file qvector.h.

359 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
360  return data()[i]; }
T * data()
Definition: qvector.h:152
GLsizeiptr size
Definition: GLee.h:1561
const T & operator[] ( int  i) const
inline

Definition at line 354 of file qvector.h.

355 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
356  return p->array[i]; }
GLfloat GLfloat p
Definition: GLee.h:5416
GLsizeiptr size
Definition: GLee.h:1561
void append ( const T &  t)

Definition at line 573 of file qvector.h.

574 {
575  if (d->ref != 1 || d->size + 1 > d->alloc) {
576  const T copy(t);
577  realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + 1, sizeof(T),
578  QTypeInfo<T>::isStatic));
579  if (QTypeInfo<T>::isComplex)
580  new (p->array + d->size) T(copy);
581  else
582  p->array[d->size] = copy;
583  } else {
584  if (QTypeInfo<T>::isComplex)
585  new (p->array + d->size) T(t);
586  else
587  p->array[d->size] = t;
588  }
589  ++d->size;
590 }
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
int alloc
Definition: qvector.h:69
GLdouble GLdouble t
Definition: GLee.h:1181
QBasicAtomicInt ref
Definition: qvector.h:68
void prepend ( const T &  t)
inline

Definition at line 378 of file qvector.h.

379 { insert(begin(), 1, t); }
iterator begin()
Definition: qvector.h:247
void insert(int i, const T &t)
Definition: qvector.h:362
GLdouble GLdouble t
Definition: GLee.h:1181
void insert ( int  i,
const T &  t 
)
inline

Definition at line 362 of file qvector.h.

363 { Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
364  insert(begin() + i, 1, t); }
iterator begin()
Definition: qvector.h:247
void insert(int i, const T &t)
Definition: qvector.h:362
GLdouble GLdouble t
Definition: GLee.h:1181
GLsizeiptr size
Definition: GLee.h:1561
void insert ( int  i,
int  n,
const T &  t 
)
inline

Definition at line 366 of file qvector.h.

367 { Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
368  insert(begin() + i, n, t); }
iterator begin()
Definition: qvector.h:247
void insert(int i, const T &t)
Definition: qvector.h:362
GLenum GLsizei n
Definition: GLee.h:3432
GLdouble GLdouble t
Definition: GLee.h:1181
GLsizeiptr size
Definition: GLee.h:1561
void replace ( int  i,
const T &  t 
)
inline

Definition at line 382 of file qvector.h.

383 {
384  Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
385  const T copy(t);
386  data()[i] = copy;
387 }
T * data()
Definition: qvector.h:152
GLdouble GLdouble t
Definition: GLee.h:1181
GLsizeiptr size
Definition: GLee.h:1561
void remove ( int  i)
inline

Definition at line 374 of file qvector.h.

375 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::remove", "index out of range");
376  erase(begin() + i, begin() + i + 1); }
iterator begin()
Definition: qvector.h:247
iterator erase(iterator begin, iterator end)
Definition: qvector.h:627
GLsizeiptr size
Definition: GLee.h:1561
void remove ( int  i,
int  n 
)
inline

Definition at line 370 of file qvector.h.

371 { Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= d->size, "QVector<T>::remove", "index out of range");
372  erase(begin() + i, begin() + i + n); }
iterator begin()
Definition: qvector.h:247
GLenum GLsizei n
Definition: GLee.h:3432
iterator erase(iterator begin, iterator end)
Definition: qvector.h:627
GLsizeiptr size
Definition: GLee.h:1561
QVector< T > & fill ( const T &  t,
int  size = -1 
)

Definition at line 665 of file qvector.h.

666 {
667  const T copy(from);
668  resize(asize < 0 ? d->size : asize);
669  if (d->size) {
670  T *i = p->array + d->size;
671  T *b = p->array;
672  while (i != b)
673  *--i = copy;
674  }
675  return *this;
676 }
void resize(int size)
Definition: qvector.h:342
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
GLsizeiptr size
Definition: GLee.h:1561
int indexOf ( const T &  t,
int  from = 0 
) const

Definition at line 698 of file qvector.h.

699 {
700  if (from < 0)
701  from = qMax(from + d->size, 0);
702  if (from < d->size) {
703  T* n = p->array + from - 1;
704  T* e = p->array + d->size;
705  while (++n != e)
706  if (*n == t)
707  return n - p->array;
708  }
709  return -1;
710 }
GLenum GLsizei n
Definition: GLee.h:3432
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
GLdouble GLdouble t
Definition: GLee.h:1181
GLsizeiptr size
Definition: GLee.h:1561
int lastIndexOf ( const T &  t,
int  from = -1 
) const

Definition at line 713 of file qvector.h.

714 {
715  if (from < 0)
716  from += d->size;
717  else if (from >= d->size)
718  from = d->size-1;
719  if (from >= 0) {
720  T* b = p->array;
721  T* n = p->array + from + 1;
722  while (n != b) {
723  if (*--n == t)
724  return n - b;
725  }
726  }
727  return -1;
728 }
GLenum GLsizei n
Definition: GLee.h:3432
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
GLdouble GLdouble t
Definition: GLee.h:1181
bool contains ( const T &  t) const

Definition at line 731 of file qvector.h.

732 {
733  T* b = p->array;
734  T* i = p->array + d->size;
735  while (i != b)
736  if (*--i == t)
737  return true;
738  return false;
739 }
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
GLdouble GLdouble t
Definition: GLee.h:1181
int count ( const T &  t) const

Definition at line 742 of file qvector.h.

743 {
744  int c = 0;
745  T* b = p->array;
746  T* i = p->array + d->size;
747  while (i != b)
748  if (*--i == t)
749  ++c;
750  return c;
751 }
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
const GLubyte * c
Definition: GLee.h:5419
int size
Definition: qvector.h:70
GLdouble GLdouble t
Definition: GLee.h:1181
iterator begin ( )
inline

Definition at line 247 of file qvector.h.

247 { detach(); return p->array; }
void detach()
Definition: qvector.h:147
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator begin ( ) const
inline

Definition at line 248 of file qvector.h.

248 { return p->array; }
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator constBegin ( ) const
inline

Definition at line 249 of file qvector.h.

249 { return p->array; }
GLfloat GLfloat p
Definition: GLee.h:5416
iterator end ( )
inline

Definition at line 250 of file qvector.h.

250 { detach(); return p->array + d->size; }
void detach()
Definition: qvector.h:147
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
const_iterator end ( ) const
inline

Definition at line 251 of file qvector.h.

251 { return p->array + d->size; }
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
const_iterator constEnd ( ) const
inline

Definition at line 252 of file qvector.h.

252 { return p->array + d->size; }
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
Q_TYPENAME QVector< T >::iterator insert ( iterator  before,
int  n,
const T &  x 
)

Definition at line 593 of file qvector.h.

594 {
595  int offset = int(before - p->array);
596  if (n != 0) {
597  const T copy(t);
598  if (d->ref != 1 || d->size + n > d->alloc)
599  realloc(d->size, QVectorData::grow(sizeOfTypedData(), d->size + n, sizeof(T),
600  QTypeInfo<T>::isStatic));
601  if (QTypeInfo<T>::isStatic) {
602  T *b = p->array + d->size;
603  T *i = p->array + d->size + n;
604  while (i != b)
605  new (--i) T;
606  i = p->array + d->size;
607  T *j = i + n;
608  b = p->array + offset;
609  while (i != b)
610  *--j = *--i;
611  i = b+n;
612  while (i != b)
613  *--i = copy;
614  } else {
615  T *b = p->array + offset;
616  T *i = b + n;
617  memmove(i, b, (d->size - offset) * sizeof(T));
618  while (i != b)
619  new (--i) T(copy);
620  }
621  d->size += n;
622  }
623  return p->array + offset;
624 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
GLintptr offset
Definition: GLee.h:1562
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
GLenum GLsizei n
Definition: GLee.h:3432
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
int alloc
Definition: qvector.h:69
GLdouble GLdouble t
Definition: GLee.h:1181
QBasicAtomicInt ref
Definition: qvector.h:68
iterator insert ( iterator  before,
const T &  x 
)
inline

Definition at line 254 of file qvector.h.

254 { return insert(before, 1, x); }
void insert(int i, const T &t)
Definition: qvector.h:362
GLenum GLint x
Definition: GLee.h:876
Q_TYPENAME QVector< T >::iterator erase ( iterator  begin,
iterator  end 
)

Definition at line 627 of file qvector.h.

628 {
629  int f = int(abegin - p->array);
630  int l = int(aend - p->array);
631  int n = l - f;
632  detach();
633  if (QTypeInfo<T>::isComplex) {
634  qCopy(p->array+l, p->array+d->size, p->array+f);
635  T *i = p->array+d->size;
636  T* b = p->array+d->size-n;
637  while (i != b) {
638  --i;
639  i->~T();
640  }
641  } else {
642  memmove(p->array + f, p->array + l, (d->size-l)*sizeof(T));
643  }
644  d->size -= n;
645  return p->array + f;
646 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
void detach()
Definition: qvector.h:147
GLenum GLsizei n
Definition: GLee.h:3432
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
Definition: qalgorithms.h:79
GLclampf f
Definition: GLee.h:9303
iterator erase ( iterator  pos)
inline

Definition at line 256 of file qvector.h.

256 { return erase(pos, pos+1); }
iterator erase(iterator begin, iterator end)
Definition: qvector.h:627
int count ( ) const
inline

Definition at line 259 of file qvector.h.

259 { return d->size; }
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
T& first ( )
inline

Definition at line 260 of file qvector.h.

260 { Q_ASSERT(!isEmpty()); return *begin(); }
iterator begin()
Definition: qvector.h:247
bool isEmpty() const
Definition: qvector.h:139
const T& first ( ) const
inline

Definition at line 261 of file qvector.h.

261 { Q_ASSERT(!isEmpty()); return *begin(); }
iterator begin()
Definition: qvector.h:247
bool isEmpty() const
Definition: qvector.h:139
T& last ( )
inline

Definition at line 262 of file qvector.h.

262 { Q_ASSERT(!isEmpty()); return *(end()-1); }
iterator end()
Definition: qvector.h:250
bool isEmpty() const
Definition: qvector.h:139
const T& last ( ) const
inline

Definition at line 263 of file qvector.h.

263 { Q_ASSERT(!isEmpty()); return *(end()-1); }
iterator end()
Definition: qvector.h:250
bool isEmpty() const
Definition: qvector.h:139
bool startsWith ( const T &  t) const
inline

Definition at line 264 of file qvector.h.

264 { return !isEmpty() && first() == t; }
T & first()
Definition: qvector.h:260
bool isEmpty() const
Definition: qvector.h:139
GLdouble GLdouble t
Definition: GLee.h:1181
bool endsWith ( const T &  t) const
inline

Definition at line 265 of file qvector.h.

265 { return !isEmpty() && last() == t; }
T & last()
Definition: qvector.h:262
bool isEmpty() const
Definition: qvector.h:139
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE QVector< T > mid ( int  pos,
int  length = -1 
) const

Definition at line 754 of file qvector.h.

755 {
756  if (length < 0)
757  length = size() - pos;
758  if (pos == 0 && length == size())
759  return *this;
760  if (pos + length > size())
761  length = size() - pos;
762  QVector<T> copy;
763  copy.reserve(length);
764  for (int i = pos; i < pos + length; ++i)
765  copy += at(i);
766  return copy;
767 }
const T & at(int i) const
Definition: qvector.h:350
GLuint GLsizei GLsizei * length
Definition: GLee.h:1713
void reserve(int size)
Definition: qvector.h:339
int size() const
Definition: qvector.h:137
Q_OUTOFLINE_TEMPLATE T value ( int  i) const

Definition at line 559 of file qvector.h.

560 {
561  if (i < 0 || i >= d->size) {
562  return T();
563  }
564  return p->array[i];
565 }
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
Q_OUTOFLINE_TEMPLATE T value ( int  i,
const T &  defaultValue 
) const

Definition at line 567 of file qvector.h.

568 {
569  return ((i < 0 || i >= d->size) ? defaultValue : p->array[i]);
570 }
QVectorData * d
Definition: qvector.h:109
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
void push_back ( const T &  t)
inline

Definition at line 281 of file qvector.h.

281 { append(t); }
void append(const T &t)
Definition: qvector.h:573
GLdouble GLdouble t
Definition: GLee.h:1181
void push_front ( const T &  t)
inline

Definition at line 282 of file qvector.h.

282 { prepend(t); }
void prepend(const T &t)
Definition: qvector.h:378
GLdouble GLdouble t
Definition: GLee.h:1181
void pop_back ( )
inline

Definition at line 283 of file qvector.h.

283 { Q_ASSERT(!isEmpty()); erase(end()-1); }
iterator end()
Definition: qvector.h:250
iterator erase(iterator begin, iterator end)
Definition: qvector.h:627
bool isEmpty() const
Definition: qvector.h:139
void pop_front ( )
inline

Definition at line 284 of file qvector.h.

284 { Q_ASSERT(!isEmpty()); erase(begin()); }
iterator begin()
Definition: qvector.h:247
iterator erase(iterator begin, iterator end)
Definition: qvector.h:627
bool isEmpty() const
Definition: qvector.h:139
bool empty ( ) const
inline

Definition at line 285 of file qvector.h.

286  { return d->size == 0; }
QVectorData * d
Definition: qvector.h:109
int size
Definition: qvector.h:70
T& front ( )
inline

Definition at line 287 of file qvector.h.

287 { return first(); }
T & first()
Definition: qvector.h:260
const_reference front ( ) const
inline

Definition at line 288 of file qvector.h.

288 { return first(); }
T & first()
Definition: qvector.h:260
reference back ( )
inline

Definition at line 289 of file qvector.h.

289 { return last(); }
T & last()
Definition: qvector.h:262
const_reference back ( ) const
inline

Definition at line 290 of file qvector.h.

290 { return last(); }
T & last()
Definition: qvector.h:262
QVector< T > & operator+= ( const QVector< T > &  l)

Definition at line 679 of file qvector.h.

680 {
681  int newSize = d->size + l.d->size;
682  realloc(d->size, newSize);
683 
684  T *w = p->array + newSize;
685  T *i = l.p->array + l.d->size;
686  T *b = l.p->array;
687  while (i != b) {
688  if (QTypeInfo<T>::isComplex)
689  new (--w) T(*--i);
690  else
691  *--w = *--i;
692  }
693  d->size = newSize;
694  return *this;
695 }
QVectorData * d
Definition: qvector.h:109
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
int size
Definition: qvector.h:70
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
Data * p
Definition: qvector.h:113
QVector<T> operator+ ( const QVector< T > &  l) const
inline

Definition at line 294 of file qvector.h.

295  { QVector n = *this; n += l; return n; }
GLenum GLsizei n
Definition: GLee.h:3432
QVector<T>& operator+= ( const T &  t)
inline

Definition at line 296 of file qvector.h.

297  { append(t); return *this; }
void append(const T &t)
Definition: qvector.h:573
GLdouble GLdouble t
Definition: GLee.h:1181
QVector<T>& operator<< ( const T &  t)
inline

Definition at line 298 of file qvector.h.

299  { append(t); return *this; }
void append(const T &t)
Definition: qvector.h:573
GLdouble GLdouble t
Definition: GLee.h:1181
QVector<T>& operator<< ( const QVector< T > &  l)
inline

Definition at line 300 of file qvector.h.

301  { *this += l; return *this; }
Q_OUTOFLINE_TEMPLATE QList< T > toList ( ) const

Definition at line 770 of file qvector.h.

771 {
772  QList<T> result;
773  result.reserve(size());
774  for (int i = 0; i < size(); ++i)
775  result.append(at(i));
776  return result;
777 }
const T & at(int i) const
Definition: qvector.h:350
void reserve(int size)
Definition: qlist.h:496
int size() const
Definition: qvector.h:137
void append(const T &t)
Definition: qlist.h:507
QVector< T > fromList ( const QList< T > &  list)
static

Definition at line 789 of file qvector.h.

790 {
791  return list.toVector();
792 }
QVector< T > toVector() const
Definition: qvector.h:780
static QVector<T> fromStdVector ( const std::vector< T > &  vector)
inlinestatic

Definition at line 308 of file qvector.h.

309  { QVector<T> tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
void reserve(int size)
Definition: qvector.h:339
OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
Definition: qalgorithms.h:79
std::vector<T> toStdVector ( ) const
inline

Definition at line 310 of file qvector.h.

311  { std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
const_iterator constEnd() const
Definition: qvector.h:252
const_iterator constBegin() const
Definition: qvector.h:249
int size() const
Definition: qvector.h:137
OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
Definition: qalgorithms.h:79

Friends And Related Function Documentation

friend class QRegion
friend

Definition at line 314 of file qvector.h.

Member Data Documentation

Definition at line 109 of file qvector.h.

Data* p

Definition at line 113 of file qvector.h.


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