QList< T > Class Template Reference

#include <backendcapabilities.h>

Class Description

template<typename T>
class QList< T >

Definition at line 40 of file backendcapabilities.h.

+ Inheritance diagram for QList< T >:

Classes

class  const_iterator
 
class  iterator
 

Public Types

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

Public Member Functions

 QList ()
 
 QList (const QList< T > &l)
 
 ~QList ()
 
QList< T > & operator= (const QList< T > &l)
 
void swap (QList< T > &other)
 
bool operator== (const QList< T > &l) const
 
bool operator!= (const QList< T > &l) const
 
int size () const
 
void detach ()
 
void detachShared ()
 
bool isDetached () const
 
void setSharable (bool sharable)
 
bool isSharedWith (const QList< T > &other) const
 
bool isEmpty () const
 
void clear ()
 
const T & at (int i) const
 
const T & operator[] (int i) const
 
T & operator[] (int i)
 
void reserve (int size)
 
void append (const T &t)
 
void append (const QList< T > &t)
 
void prepend (const T &t)
 
void insert (int i, const T &t)
 
void replace (int i, const T &t)
 
void removeAt (int i)
 
int removeAll (const T &t)
 
bool removeOne (const T &t)
 
takeAt (int i)
 
takeFirst ()
 
takeLast ()
 
void move (int from, int to)
 
void swap (int i, int j)
 
int indexOf (const T &t, int from=0) const
 
int lastIndexOf (const T &t, int from=-1) const
 
QBool 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, const T &t)
 
iterator erase (iterator pos)
 
iterator erase (iterator first, iterator last)
 
int count () const
 
int length () const
 
T & first ()
 
const T & first () const
 
T & last ()
 
const T & last () const
 
void removeFirst ()
 
void removeLast ()
 
bool startsWith (const T &t) const
 
bool endsWith (const T &t) const
 
QList< 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)
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
void pop_front ()
 
void pop_back ()
 
bool empty () const
 
QList< T > & operator+= (const QList< T > &l)
 
QList< T > operator+ (const QList< T > &l) const
 
QList< T > & operator+= (const T &t)
 
QList< T > & operator<< (const T &t)
 
QList< T > & operator<< (const QList< T > &l)
 
QVector< T > toVector () const
 
QSet< T > toSet () const
 
std::list< T > toStdList () const
 

Static Public Member Functions

static QList< T > fromVector (const QVector< T > &vector)
 
static QList< T > fromSet (const QSet< T > &set)
 
static QList< T > fromStdList (const std::list< T > &list)
 

Friends

class iterator
 
class const_iterator
 

Member Typedef Documentation

typedef iterator Iterator

Definition at line 278 of file qlist.h.

Definition at line 279 of file qlist.h.

typedef int size_type

Definition at line 305 of file qlist.h.

typedef T value_type

Definition at line 306 of file qlist.h.

typedef value_type* pointer

Definition at line 307 of file qlist.h.

typedef const value_type* const_pointer

Definition at line 308 of file qlist.h.

Definition at line 309 of file qlist.h.

typedef const value_type& const_reference

Definition at line 310 of file qlist.h.

typedef qptrdiff difference_type

Definition at line 311 of file qlist.h.

Constructor & Destructor Documentation

QList ( )
inline

Definition at line 121 of file qlist.h.

121 : d(&QListData::shared_null) { d->ref.ref(); }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
static Data shared_null
Definition: qlist.h:86
QList ( const QList< T > &  l)
inline

Definition at line 122 of file qlist.h.

122 : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
QBasicAtomicInt ref
Definition: qlist.h:73
uint sharable
Definition: qlist.h:75
QListData::Data * d
Definition: qlist.h:118
Q_OUTOFLINE_TEMPLATE ~QList ( )

Definition at line 729 of file qlist.h.

730 {
731  if (!d->ref.deref())
732  free(d);
733 }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118

Member Function Documentation

Q_INLINE_TEMPLATE QList< T > & operator= ( const QList< T > &  l)

Definition at line 437 of file qlist.h.

438 {
439  if (d != l.d) {
440  QListData::Data *o = l.d;
441  o->ref.ref();
442  if (!d->ref.deref())
443  free(d);
444  d = o;
445  if (!d->sharable)
446  detach_helper();
447  }
448  return *this;
449 }
QBasicAtomicInt ref
Definition: qlist.h:73
uint sharable
Definition: qlist.h:75
QListData::Data * d
Definition: qlist.h:118
void swap ( QList< T > &  other)
inline

Definition at line 129 of file qlist.h.

129 { qSwap(d, other.d); }
QListData::Data * d
Definition: qlist.h:118
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
Q_OUTOFLINE_TEMPLATE bool operator== ( const QList< T > &  l) const

Definition at line 736 of file qlist.h.

737 {
738  if (p.size() != l.p.size())
739  return false;
740  if (d == l.d)
741  return true;
742  Node *i = reinterpret_cast<Node *>(p.end());
743  Node *b = reinterpret_cast<Node *>(p.begin());
744  Node *li = reinterpret_cast<Node *>(l.p.end());
745  while (i != b) {
746  --i; --li;
747  if (!(i->t() == li->t()))
748  return false;
749  }
750  return true;
751 }
QListData p
Definition: qlist.h:118
QListData::Data * d
Definition: qlist.h:118
int size() const
Definition: qlist.h:98
GLubyte GLubyte b
Definition: GLee.h:5404
void ** end() const
Definition: qlist.h:102
GLfloat GLfloat p
Definition: GLee.h:5416
bool operator!= ( const QList< T > &  l) const
inline

Definition at line 135 of file qlist.h.

135 { return !(*this == l); }
int size ( ) const
inline

Definition at line 137 of file qlist.h.

137 { return p.size(); }
GLfloat GLfloat p
Definition: GLee.h:5416
void detach ( )
inline

Definition at line 139 of file qlist.h.

139 { if (d->ref != 1) detach_helper(); }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
void detachShared ( )
inline

Definition at line 141 of file qlist.h.

142  {
143  // The "this->" qualification is needed for GCCE.
144  if (d->ref != 1 && this->d != &QListData::shared_null)
145  detach_helper();
146  }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
static Data shared_null
Definition: qlist.h:86
bool isDetached ( ) const
inline

Definition at line 148 of file qlist.h.

148 { return d->ref == 1; }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
void setSharable ( bool  sharable)
inline

Definition at line 149 of file qlist.h.

149 { if (!sharable) detach(); d->sharable = sharable; }
uint sharable
Definition: qlist.h:75
QListData::Data * d
Definition: qlist.h:118
void detach()
Definition: qlist.h:139
bool isSharedWith ( const QList< T > &  other) const
inline

Definition at line 150 of file qlist.h.

150 { return d == other.d; }
QListData::Data * d
Definition: qlist.h:118
bool isEmpty ( ) const
inline

Definition at line 152 of file qlist.h.

152 { return p.isEmpty(); }
GLfloat GLfloat p
Definition: GLee.h:5416
Q_OUTOFLINE_TEMPLATE void clear ( )

Definition at line 764 of file qlist.h.

765 {
766  *this = QList<T>();
767 }
const T & at ( int  i) const
inline

Definition at line 468 of file qlist.h.

469 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
470  return reinterpret_cast<Node *>(p.at(i))->t(); }
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
const T & operator[] ( int  i) const
inline

Definition at line 472 of file qlist.h.

473 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::operator[]", "index out of range");
474  return reinterpret_cast<Node *>(p.at(i))->t(); }
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
T & operator[] ( int  i)
inline

Definition at line 476 of file qlist.h.

477 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::operator[]", "index out of range");
478  detach(); return reinterpret_cast<Node *>(p.at(i))->t(); }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE void reserve ( int  size)

Definition at line 496 of file qlist.h.

497 {
498  if (d->alloc < alloc) {
499  if (d->ref != 1)
500  detach_helper(alloc);
501  else
502  p.realloc(alloc);
503  }
504 }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
GLfloat GLfloat p
Definition: GLee.h:5416
Q_OUTOFLINE_TEMPLATE void append ( const T &  t)

Definition at line 507 of file qlist.h.

508 {
509  if (d->ref != 1) {
510  Node *n = detach_helper_grow(INT_MAX, 1);
511  QT_TRY {
512  node_construct(n, t);
513  } QT_CATCH(...) {
514  --d->end;
515  QT_RETHROW;
516  }
517  } else {
518  if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
519  Node *n = reinterpret_cast<Node *>(p.append());
520  QT_TRY {
521  node_construct(n, t);
522  } QT_CATCH(...) {
523  --d->end;
524  QT_RETHROW;
525  }
526  } else {
527  Node *n, copy;
528  node_construct(&copy, t); // t might be a reference to an object in the array
529  QT_TRY {
530  n = reinterpret_cast<Node *>(p.append());;
531  } QT_CATCH(...) {
532  node_destruct(&copy);
533  QT_RETHROW;
534  }
535  *n = copy;
536  }
537  }
538 }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
void append ( const QList< T > &  t)
inline

Definition at line 841 of file qlist.h.

842 {
843  *this += t;
844 }
GLdouble GLdouble t
Definition: GLee.h:1181
void prepend ( const T &  t)
inline

Definition at line 541 of file qlist.h.

542 {
543  if (d->ref != 1) {
544  Node *n = detach_helper_grow(0, 1);
545  QT_TRY {
546  node_construct(n, t);
547  } QT_CATCH(...) {
548  ++d->begin;
549  QT_RETHROW;
550  }
551  } else {
552  if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
553  Node *n = reinterpret_cast<Node *>(p.prepend());
554  QT_TRY {
555  node_construct(n, t);
556  } QT_CATCH(...) {
557  ++d->begin;
558  QT_RETHROW;
559  }
560  } else {
561  Node *n, copy;
562  node_construct(&copy, t); // t might be a reference to an object in the array
563  QT_TRY {
564  n = reinterpret_cast<Node *>(p.prepend());;
565  } QT_CATCH(...) {
566  node_destruct(&copy);
567  QT_RETHROW;
568  }
569  *n = copy;
570  }
571  }
572 }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
void insert ( int  i,
const T &  t 
)
inline

Definition at line 575 of file qlist.h.

576 {
577  if (d->ref != 1) {
578  Node *n = detach_helper_grow(i, 1);
579  QT_TRY {
580  node_construct(n, t);
581  } QT_CATCH(...) {
582  p.remove(i);
583  QT_RETHROW;
584  }
585  } else {
586  if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
587  Node *n = reinterpret_cast<Node *>(p.insert(i));
588  QT_TRY {
589  node_construct(n, t);
590  } QT_CATCH(...) {
591  p.remove(i);
592  QT_RETHROW;
593  }
594  } else {
595  Node *n, copy;
596  node_construct(&copy, t); // t might be a reference to an object in the array
597  QT_TRY {
598  n = reinterpret_cast<Node *>(p.insert(i));;
599  } QT_CATCH(...) {
600  node_destruct(&copy);
601  QT_RETHROW;
602  }
603  *n = copy;
604  }
605  }
606 }
QBasicAtomicInt ref
Definition: qlist.h:73
QListData::Data * d
Definition: qlist.h:118
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
void replace ( int  i,
const T &  t 
)
inline

Definition at line 609 of file qlist.h.

610 {
611  Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::replace", "index out of range");
612  detach();
613  reinterpret_cast<Node *>(p.at(i))->t() = t;
614 }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
void removeAt ( int  i)
inline

Definition at line 480 of file qlist.h.

481 { if(i >= 0 && i < p.size()) { detach();
482  node_destruct(reinterpret_cast<Node *>(p.at(i))); p.remove(i); } }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
Q_OUTOFLINE_TEMPLATE int removeAll ( const T &  t)

Definition at line 770 of file qlist.h.

771 {
772  int index = indexOf(_t);
773  if (index == -1)
774  return 0;
775 
776  const T t = _t;
777  detach();
778 
779  Node *i = reinterpret_cast<Node *>(p.at(index));
780  Node *e = reinterpret_cast<Node *>(p.end());
781  Node *n = i;
782  node_destruct(i);
783  while (++i != e) {
784  if (i->t() == t)
785  node_destruct(i);
786  else
787  *n++ = *i;
788  }
789 
790  int removedCount = e - n;
791  d->end -= removedCount;
792  return removedCount;
793 }
QListData::Data * d
Definition: qlist.h:118
void detach()
Definition: qlist.h:139
int indexOf(const T &t, int from=0) const
Definition: qlist.h:847
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
GLuint index
Definition: GLee.h:1704
Q_OUTOFLINE_TEMPLATE bool removeOne ( const T &  t)

Definition at line 796 of file qlist.h.

797 {
798  int index = indexOf(_t);
799  if (index != -1) {
800  removeAt(index);
801  return true;
802  }
803  return false;
804 }
void removeAt(int i)
Definition: qlist.h:480
int indexOf(const T &t, int from=0) const
Definition: qlist.h:847
GLuint index
Definition: GLee.h:1704
T takeAt ( int  i)
inline

Definition at line 484 of file qlist.h.

485 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::take", "index out of range");
486  detach(); Node *n = reinterpret_cast<Node *>(p.at(i)); T t = n->t(); node_destruct(n);
487  p.remove(i); return t; }
void detach()
Definition: qlist.h:139
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
T takeFirst ( )
inline

Definition at line 489 of file qlist.h.

490 { T t = first(); removeFirst(); return t; }
T & first()
Definition: qlist.h:282
GLdouble GLdouble t
Definition: GLee.h:1181
void removeFirst()
Definition: qlist.h:286
T takeLast ( )
inline

Definition at line 492 of file qlist.h.

493 { T t = last(); removeLast(); return t; }
T & last()
Definition: qlist.h:284
void removeLast()
Definition: qlist.h:287
GLdouble GLdouble t
Definition: GLee.h:1181
void move ( int  from,
int  to 
)
inline

Definition at line 628 of file qlist.h.

629 {
630  Q_ASSERT_X(from >= 0 && from < p.size() && to >= 0 && to < p.size(),
631  "QList<T>::move", "index out of range");
632  detach();
633  p.move(from, to);
634 }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
void swap ( int  i,
int  j 
)
inline

Definition at line 617 of file qlist.h.

618 {
619  Q_ASSERT_X(i >= 0 && i < p.size() && j >= 0 && j < p.size(),
620  "QList<T>::swap", "index out of range");
621  detach();
622  void *t = d->array[d->begin + i];
623  d->array[d->begin + i] = d->array[d->begin + j];
624  d->array[d->begin + j] = t;
625 }
QListData::Data * d
Definition: qlist.h:118
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
void * array[1]
Definition: qlist.h:76
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE int indexOf ( const T &  t,
int  from = 0 
) const

Definition at line 847 of file qlist.h.

848 {
849  if (from < 0)
850  from = qMax(from + p.size(), 0);
851  if (from < p.size()) {
852  Node *n = reinterpret_cast<Node *>(p.at(from -1));
853  Node *e = reinterpret_cast<Node *>(p.end());
854  while (++n != e)
855  if (n->t() == t)
856  return int(n - reinterpret_cast<Node *>(p.begin()));
857  }
858  return -1;
859 }
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE int lastIndexOf ( const T &  t,
int  from = -1 
) const

Definition at line 862 of file qlist.h.

863 {
864  if (from < 0)
865  from += p.size();
866  else if (from >= p.size())
867  from = p.size()-1;
868  if (from >= 0) {
869  Node *b = reinterpret_cast<Node *>(p.begin());
870  Node *n = reinterpret_cast<Node *>(p.at(from + 1));
871  while (n-- != b) {
872  if (n->t() == t)
873  return n - b;
874  }
875  }
876  return -1;
877 }
GLenum GLsizei n
Definition: GLee.h:3432
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE QBool contains ( const T &  t) const

Definition at line 880 of file qlist.h.

881 {
882  Node *b = reinterpret_cast<Node *>(p.begin());
883  Node *i = reinterpret_cast<Node *>(p.end());
884  while (i-- != b)
885  if (i->t() == t)
886  return QBool(true);
887  return QBool(false);
888 }
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE int count ( const T &  t) const

Definition at line 891 of file qlist.h.

892 {
893  int c = 0;
894  Node *b = reinterpret_cast<Node *>(p.begin());
895  Node *i = reinterpret_cast<Node *>(p.end());
896  while (i-- != b)
897  if (i->t() == t)
898  ++c;
899  return c;
900 }
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
const GLubyte * c
Definition: GLee.h:5419
GLdouble GLdouble t
Definition: GLee.h:1181
iterator begin ( )
inline

Definition at line 267 of file qlist.h.

267 { detach(); return reinterpret_cast<Node *>(p.begin()); }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator begin ( ) const
inline

Definition at line 268 of file qlist.h.

268 { return reinterpret_cast<Node *>(p.begin()); }
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator constBegin ( ) const
inline

Definition at line 269 of file qlist.h.

269 { return reinterpret_cast<Node *>(p.begin()); }
GLfloat GLfloat p
Definition: GLee.h:5416
iterator end ( )
inline

Definition at line 270 of file qlist.h.

270 { detach(); return reinterpret_cast<Node *>(p.end()); }
void detach()
Definition: qlist.h:139
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator end ( ) const
inline

Definition at line 271 of file qlist.h.

271 { return reinterpret_cast<Node *>(p.end()); }
GLfloat GLfloat p
Definition: GLee.h:5416
const_iterator constEnd ( ) const
inline

Definition at line 272 of file qlist.h.

272 { return reinterpret_cast<Node *>(p.end()); }
GLfloat GLfloat p
Definition: GLee.h:5416
QList< T >::iterator insert ( iterator  before,
const T &  t 
)
inline

Definition at line 451 of file qlist.h.

452 {
453  int iBefore = int(before.i - reinterpret_cast<Node *>(p.begin()));
454  Node *n = reinterpret_cast<Node *>(p.insert(iBefore));
455  QT_TRY {
456  node_construct(n, t);
457  } QT_CATCH(...) {
458  p.remove(iBefore);
459  QT_RETHROW;
460  }
461  return n;
462 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
QList< T >::iterator erase ( iterator  pos)
inline

Definition at line 464 of file qlist.h.

465 { node_destruct(it.i);
466  return reinterpret_cast<Node *>(p.erase(reinterpret_cast<void**>(it.i))); }
GLfloat GLfloat p
Definition: GLee.h:5416
iterator erase ( iterator  first,
iterator  last 
)
int count ( ) const
inline

Definition at line 280 of file qlist.h.

280 { return p.size(); }
GLfloat GLfloat p
Definition: GLee.h:5416
int length ( ) const
inline

Definition at line 281 of file qlist.h.

281 { return p.size(); } // Same as count()
GLfloat GLfloat p
Definition: GLee.h:5416
T& first ( )
inline

Definition at line 282 of file qlist.h.

282 { Q_ASSERT(!isEmpty()); return *begin(); }
iterator begin()
Definition: qlist.h:267
bool isEmpty() const
Definition: qlist.h:152
const T& first ( ) const
inline

Definition at line 283 of file qlist.h.

283 { Q_ASSERT(!isEmpty()); return at(0); }
const T & at(int i) const
Definition: qlist.h:468
bool isEmpty() const
Definition: qlist.h:152
T& last ( )
inline

Definition at line 284 of file qlist.h.

284 { Q_ASSERT(!isEmpty()); return *(--end()); }
iterator end()
Definition: qlist.h:270
bool isEmpty() const
Definition: qlist.h:152
const T& last ( ) const
inline

Definition at line 285 of file qlist.h.

285 { Q_ASSERT(!isEmpty()); return at(count() - 1); }
const T & at(int i) const
Definition: qlist.h:468
int count() const
Definition: qlist.h:280
bool isEmpty() const
Definition: qlist.h:152
void removeFirst ( )
inline

Definition at line 286 of file qlist.h.

286 { Q_ASSERT(!isEmpty()); erase(begin()); }
iterator erase(iterator pos)
Definition: qlist.h:464
iterator begin()
Definition: qlist.h:267
bool isEmpty() const
Definition: qlist.h:152
void removeLast ( )
inline

Definition at line 287 of file qlist.h.

287 { Q_ASSERT(!isEmpty()); erase(--end()); }
iterator erase(iterator pos)
Definition: qlist.h:464
iterator end()
Definition: qlist.h:270
bool isEmpty() const
Definition: qlist.h:152
bool startsWith ( const T &  t) const
inline

Definition at line 288 of file qlist.h.

288 { return !isEmpty() && first() == t; }
T & first()
Definition: qlist.h:282
GLdouble GLdouble t
Definition: GLee.h:1181
bool isEmpty() const
Definition: qlist.h:152
bool endsWith ( const T &  t) const
inline

Definition at line 289 of file qlist.h.

289 { return !isEmpty() && last() == t; }
T & last()
Definition: qlist.h:284
GLdouble GLdouble t
Definition: GLee.h:1181
bool isEmpty() const
Definition: qlist.h:152
Q_OUTOFLINE_TEMPLATE QList< T > mid ( int  pos,
int  length = -1 
) const

Definition at line 637 of file qlist.h.

638 {
639  if (alength < 0 || pos + alength > size())
640  alength = size() - pos;
641  if (pos == 0 && alength == size())
642  return *this;
643  QList<T> cpy;
644  if (alength <= 0)
645  return cpy;
646  cpy.reserve(alength);
647  cpy.d->end = alength;
648  QT_TRY {
649  cpy.node_copy(reinterpret_cast<Node *>(cpy.p.begin()),
650  reinterpret_cast<Node *>(cpy.p.end()),
651  reinterpret_cast<Node *>(p.begin() + pos));
652  } QT_CATCH(...) {
653  // restore the old end
654  cpy.d->end = 0;
655  QT_RETHROW;
656  }
657  return cpy;
658 }
void ** begin() const
Definition: qlist.h:101
void reserve(int size)
Definition: qlist.h:496
QListData p
Definition: qlist.h:118
int size() const
Definition: qlist.h:137
QListData::Data * d
Definition: qlist.h:118
void ** end() const
Definition: qlist.h:102
GLfloat GLfloat p
Definition: GLee.h:5416
Q_OUTOFLINE_TEMPLATE T value ( int  i) const

Definition at line 661 of file qlist.h.

662 {
663  if (i < 0 || i >= p.size()) {
664  return T();
665  }
666  return reinterpret_cast<Node *>(p.at(i))->t();
667 }
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
Q_OUTOFLINE_TEMPLATE T value ( int  i,
const T &  defaultValue 
) const

Definition at line 670 of file qlist.h.

671 {
672  return ((i < 0 || i >= p.size()) ? defaultValue : reinterpret_cast<Node *>(p.at(i))->t());
673 }
GLfloat GLfloat p
Definition: GLee.h:5416
GLdouble GLdouble t
Definition: GLee.h:1181
void push_back ( const T &  t)
inline

Definition at line 296 of file qlist.h.

296 { append(t); }
void append(const T &t)
Definition: qlist.h:507
GLdouble GLdouble t
Definition: GLee.h:1181
void push_front ( const T &  t)
inline

Definition at line 297 of file qlist.h.

297 { prepend(t); }
void prepend(const T &t)
Definition: qlist.h:541
GLdouble GLdouble t
Definition: GLee.h:1181
T& front ( )
inline

Definition at line 298 of file qlist.h.

298 { return first(); }
T & first()
Definition: qlist.h:282
const T& front ( ) const
inline

Definition at line 299 of file qlist.h.

299 { return first(); }
T & first()
Definition: qlist.h:282
T& back ( )
inline

Definition at line 300 of file qlist.h.

300 { return last(); }
T & last()
Definition: qlist.h:284
const T& back ( ) const
inline

Definition at line 301 of file qlist.h.

301 { return last(); }
T & last()
Definition: qlist.h:284
void pop_front ( )
inline

Definition at line 302 of file qlist.h.

302 { removeFirst(); }
void removeFirst()
Definition: qlist.h:286
void pop_back ( )
inline

Definition at line 303 of file qlist.h.

303 { removeLast(); }
void removeLast()
Definition: qlist.h:287
bool empty ( ) const
inline

Definition at line 304 of file qlist.h.

304 { return isEmpty(); }
bool isEmpty() const
Definition: qlist.h:152
Q_OUTOFLINE_TEMPLATE QList< T > & operator+= ( const QList< T > &  l)

Definition at line 818 of file qlist.h.

819 {
820  if (!l.isEmpty()) {
821  if (isEmpty()) {
822  *this = l;
823  } else {
824  Node *n = (d->ref != 1)
825  ? detach_helper_grow(INT_MAX, l.size())
826  : reinterpret_cast<Node *>(p.append2(l.p));
827  QT_TRY {
828  node_copy(n, reinterpret_cast<Node *>(p.end()),
829  reinterpret_cast<Node *>(l.p.begin()));
830  } QT_CATCH(...) {
831  // restore the old end
832  d->end -= int(reinterpret_cast<Node *>(p.end()) - n);
833  QT_RETHROW;
834  }
835  }
836  }
837  return *this;
838 }
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
QBasicAtomicInt ref
Definition: qlist.h:73
void ** begin() const
Definition: qlist.h:101
QListData p
Definition: qlist.h:118
int size() const
Definition: qlist.h:137
QListData::Data * d
Definition: qlist.h:118
GLenum GLsizei n
Definition: GLee.h:3432
GLfloat GLfloat p
Definition: GLee.h:5416
bool isEmpty() const
Definition: qlist.h:152
QList<T> operator+ ( const QList< T > &  l) const
inline

Definition at line 329 of file qlist.h.

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

Definition at line 331 of file qlist.h.

332  { append(t); return *this; }
void append(const T &t)
Definition: qlist.h:507
GLdouble GLdouble t
Definition: GLee.h:1181
QList<T>& operator<< ( const T &  t)
inline

Definition at line 333 of file qlist.h.

334  { append(t); return *this; }
void append(const T &t)
Definition: qlist.h:507
GLdouble GLdouble t
Definition: GLee.h:1181
QList<T>& operator<< ( const QList< T > &  l)
inline

Definition at line 335 of file qlist.h.

336  { *this += l; return *this; }
Q_OUTOFLINE_TEMPLATE QVector< T > toVector ( ) const

Definition at line 780 of file qvector.h.

781 {
782  QVector<T> result(size());
783  for (int i = 0; i < size(); ++i)
784  result[i] = at(i);
785  return result;
786 }
int size() const
Definition: qlist.h:137
const T & at(int i) const
Definition: qlist.h:468
Q_OUTOFLINE_TEMPLATE QSet< T > toSet ( ) const

Definition at line 309 of file qset.h.

310 {
311  QSet<T> result;
312  result.reserve(size());
313  for (int i = 0; i < size(); ++i)
314  result.insert(at(i));
315  return result;
316 }
void reserve(int size)
Definition: qset.h:241
int size() const
Definition: qlist.h:137
const T & at(int i) const
Definition: qlist.h:468
const_iterator insert(const T &value)
Definition: qset.h:179
QList< T > fromVector ( const QVector< T > &  vector)
static

Definition at line 795 of file qvector.h.

796 {
797  return vector.toList();
798 }
QList< T > toList() const
Definition: qvector.h:770
QList< T > fromSet ( const QSet< T > &  set)
static

Definition at line 325 of file qset.h.

326 {
327  return set.toList();
328 }
QList< T > toList() const
Definition: qset.h:296
static QList<T> fromStdList ( const std::list< T > &  list)
inlinestatic

Definition at line 345 of file qlist.h.

346  { QList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
Definition: qalgorithms.h:79
std::list<T> toStdList ( ) const
inline

Definition at line 347 of file qlist.h.

348  { std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
const_iterator constEnd() const
Definition: qlist.h:272
const_iterator constBegin() const
Definition: qlist.h:269
OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
Definition: qalgorithms.h:79

Friends And Related Function Documentation

friend class iterator
friend

Definition at line 226 of file qlist.h.

friend class const_iterator
friend

Definition at line 264 of file qlist.h.

Member Data Documentation

Definition at line 118 of file qlist.h.

Definition at line 118 of file qlist.h.


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