QSet< T > Class Template Reference

#include <qcontainerfwd.h>

Class Description

template<class T>
class QSet< T >

Definition at line 62 of file qcontainerfwd.h.

Classes

class  const_iterator
 
class  iterator
 

Public Types

typedef iterator Iterator
 
typedef const_iterator ConstIterator
 
typedef T key_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
 
typedef int size_type
 

Public Member Functions

 QSet ()
 
 QSet (const QSet< T > &other)
 
QSet< T > & operator= (const QSet< T > &other)
 
void swap (QSet< T > &other)
 
bool operator== (const QSet< T > &other) const
 
bool operator!= (const QSet< T > &other) const
 
int size () const
 
bool isEmpty () const
 
int capacity () const
 
void reserve (int size)
 
void squeeze ()
 
void detach ()
 
bool isDetached () const
 
void setSharable (bool sharable)
 
void clear ()
 
bool remove (const T &value)
 
bool contains (const T &value) const
 
bool contains (const QSet< T > &set) const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator constBegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator constEnd () const
 
iterator erase (iterator i)
 
int count () const
 
const_iterator insert (const T &value)
 
iterator find (const T &value)
 
const_iterator find (const T &value) const
 
const_iterator constFind (const T &value) const
 
QSet< T > & unite (const QSet< T > &other)
 
QSet< T > & intersect (const QSet< T > &other)
 
QSet< T > & subtract (const QSet< T > &other)
 
bool empty () const
 
QSet< T > & operator<< (const T &value)
 
QSet< T > & operator|= (const QSet< T > &other)
 
QSet< T > & operator|= (const T &value)
 
QSet< T > & operator&= (const QSet< T > &other)
 
QSet< T > & operator&= (const T &value)
 
QSet< T > & operator+= (const QSet< T > &other)
 
QSet< T > & operator+= (const T &value)
 
QSet< T > & operator-= (const QSet< T > &other)
 
QSet< T > & operator-= (const T &value)
 
QSet< T > operator| (const QSet< T > &other) const
 
QSet< T > operator& (const QSet< T > &other) const
 
QSet< T > operator+ (const QSet< T > &other) const
 
QSet< T > operator- (const QSet< T > &other) const
 
QSet< T > operator| (const QSet< T > &other)
 
QSet< T > operator& (const QSet< T > &other)
 
QSet< T > operator+ (const QSet< T > &other)
 
QSet< T > operator- (const QSet< T > &other)
 
QList< T > toList () const
 
QList< T > values () const
 

Static Public Member Functions

static QSet< T > fromList (const QList< T > &list)
 

Member Typedef Documentation

typedef iterator Iterator

Definition at line 176 of file qset.h.

Definition at line 177 of file qset.h.

typedef T key_type

Definition at line 190 of file qset.h.

typedef T value_type

Definition at line 191 of file qset.h.

typedef value_type* pointer

Definition at line 192 of file qset.h.

typedef const value_type* const_pointer

Definition at line 193 of file qset.h.

Definition at line 194 of file qset.h.

typedef const value_type& const_reference

Definition at line 195 of file qset.h.

typedef qptrdiff difference_type

Definition at line 196 of file qset.h.

typedef int size_type

Definition at line 197 of file qset.h.

Constructor & Destructor Documentation

QSet ( )
inline

Definition at line 59 of file qset.h.

59 {}
QSet ( const QSet< T > &  other)
inline

Definition at line 60 of file qset.h.

60 : q_hash(other.q_hash) {}

Member Function Documentation

QSet<T>& operator= ( const QSet< T > &  other)
inline

Definition at line 62 of file qset.h.

63  { q_hash = other.q_hash; return *this; }
void swap ( QSet< T > &  other)
inline

Definition at line 68 of file qset.h.

68 { q_hash.swap(other.q_hash); }
void swap(QHash< Key, T > &other)
Definition: qhash.h:290
bool operator== ( const QSet< T > &  other) const
inline

Definition at line 70 of file qset.h.

71  { return q_hash == other.q_hash; }
bool operator!= ( const QSet< T > &  other) const
inline

Definition at line 72 of file qset.h.

73  { return q_hash != other.q_hash; }
int size ( ) const
inline

Definition at line 75 of file qset.h.

75 { return q_hash.size(); }
int size() const
Definition: qhash.h:295
bool isEmpty ( ) const
inline

Definition at line 77 of file qset.h.

77 { return q_hash.isEmpty(); }
bool isEmpty() const
Definition: qhash.h:297
int capacity ( ) const
inline

Definition at line 79 of file qset.h.

79 { return q_hash.capacity(); }
int capacity() const
Definition: qhash.h:299
Q_INLINE_TEMPLATE void reserve ( int  size)
inline

Definition at line 241 of file qset.h.

241 { q_hash.reserve(asize); }
void reserve(int size)
Definition: qhash.h:846
void squeeze ( )
inline

Definition at line 81 of file qset.h.

81 { q_hash.squeeze(); }
void squeeze()
Definition: qhash.h:301
void detach ( )
inline

Definition at line 83 of file qset.h.

83 { q_hash.detach(); }
void detach()
Definition: qhash.h:303
bool isDetached ( ) const
inline

Definition at line 84 of file qset.h.

84 { return q_hash.isDetached(); }
bool isDetached() const
Definition: qhash.h:304
void setSharable ( bool  sharable)
inline

Definition at line 85 of file qset.h.

85 { q_hash.setSharable(sharable); }
void setSharable(bool sharable)
Definition: qhash.h:305
void clear ( )
inline

Definition at line 87 of file qset.h.

87 { q_hash.clear(); }
void clear()
Definition: qhash.h:574
bool remove ( const T &  value)
inline

Definition at line 89 of file qset.h.

89 { return q_hash.remove(value) != 0; }
int remove(const Key &key)
Definition: qhash.h:784
GLsizei const GLfloat * value
Definition: GLee.h:1742
bool contains ( const T &  value) const
inline

Definition at line 91 of file qset.h.

91 { return q_hash.contains(value); }
GLsizei const GLfloat * value
Definition: GLee.h:1742
bool contains(const Key &key) const
Definition: qhash.h:872
Q_INLINE_TEMPLATE bool contains ( const QSet< T > &  set) const

Definition at line 284 of file qset.h.

285 {
286  typename QSet<T>::const_iterator i = other.constBegin();
287  while (i != other.constEnd()) {
288  if (!contains(*i))
289  return false;
290  ++i;
291  }
292  return true;
293 }
bool contains(const T &value) const
Definition: qset.h:91
iterator begin ( )
inline

Definition at line 166 of file qset.h.

166 { return q_hash.begin(); }
iterator begin()
Definition: qhash.h:464
const_iterator begin ( ) const
inline

Definition at line 167 of file qset.h.

167 { return q_hash.begin(); }
iterator begin()
Definition: qhash.h:464
const_iterator constBegin ( ) const
inline

Definition at line 168 of file qset.h.

168 { return q_hash.constBegin(); }
const_iterator constBegin() const
Definition: qhash.h:466
iterator end ( )
inline

Definition at line 169 of file qset.h.

169 { return q_hash.end(); }
iterator end()
Definition: qhash.h:467
const_iterator end ( ) const
inline

Definition at line 170 of file qset.h.

170 { return q_hash.end(); }
iterator end()
Definition: qhash.h:467
const_iterator constEnd ( ) const
inline

Definition at line 171 of file qset.h.

171 { return q_hash.constEnd(); }
const_iterator constEnd() const
Definition: qhash.h:469
iterator erase ( iterator  i)
inline

Definition at line 172 of file qset.h.

173  { return q_hash.erase(reinterpret_cast<typename Hash::iterator &>(i)); }
iterator erase(iterator it)
Definition: qhash.h:827
int count ( ) const
inline

Definition at line 178 of file qset.h.

178 { return q_hash.count(); }
int count(const Key &key) const
Definition: qhash.h:719
const_iterator insert ( const T &  value)
inline

Definition at line 179 of file qset.h.

180  { return static_cast<typename Hash::const_iterator>(q_hash.insert(value,
181  QHashDummyValue())); }
GLsizei const GLfloat * value
Definition: GLee.h:1742
friend class const_iterator
Definition: qhash.h:461
iterator insert(const Key &key, const T &value)
Definition: qhash.h:753
iterator find ( const T &  value)
inline

Definition at line 182 of file qset.h.

182 { return q_hash.find(value); }
iterator find(const Key &key)
Definition: qhash.h:865
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator find ( const T &  value) const
inline

Definition at line 183 of file qset.h.

183 { return q_hash.find(value); }
iterator find(const Key &key)
Definition: qhash.h:865
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator constFind ( const T &  value) const
inline

Definition at line 184 of file qset.h.

184 { return find(value); }
iterator find(const T &value)
Definition: qset.h:182
GLsizei const GLfloat * value
Definition: GLee.h:1742
Q_INLINE_TEMPLATE QSet< T > & unite ( const QSet< T > &  other)

Definition at line 244 of file qset.h.

245 {
246  QSet<T> copy(other);
247  typename QSet<T>::const_iterator i = copy.constEnd();
248  while (i != copy.constBegin()) {
249  --i;
250  insert(*i);
251  }
252  return *this;
253 }
const_iterator insert(const T &value)
Definition: qset.h:179
Q_INLINE_TEMPLATE QSet< T > & intersect ( const QSet< T > &  other)

Definition at line 256 of file qset.h.

257 {
258  QSet<T> copy1(*this);
259  QSet<T> copy2(other);
260  typename QSet<T>::const_iterator i = copy1.constEnd();
261  while (i != copy1.constBegin()) {
262  --i;
263  if (!copy2.contains(*i))
264  remove(*i);
265  }
266  return *this;
267 }
Q_INLINE_TEMPLATE QSet< T > & subtract ( const QSet< T > &  other)

Definition at line 270 of file qset.h.

271 {
272  QSet<T> copy1(*this);
273  QSet<T> copy2(other);
274  typename QSet<T>::const_iterator i = copy1.constEnd();
275  while (i != copy1.constBegin()) {
276  --i;
277  if (copy2.contains(*i))
278  remove(*i);
279  }
280  return *this;
281 }
bool empty ( ) const
inline

Definition at line 199 of file qset.h.

199 { return isEmpty(); }
bool isEmpty() const
Definition: qset.h:77
QSet<T>& operator<< ( const T &  value)
inline

Definition at line 201 of file qset.h.

201 { insert(value); return *this; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator insert(const T &value)
Definition: qset.h:179
QSet<T>& operator|= ( const QSet< T > &  other)
inline

Definition at line 202 of file qset.h.

202 { unite(other); return *this; }
QSet< T > & unite(const QSet< T > &other)
Definition: qset.h:244
QSet<T>& operator|= ( const T &  value)
inline

Definition at line 203 of file qset.h.

203 { insert(value); return *this; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator insert(const T &value)
Definition: qset.h:179
QSet<T>& operator&= ( const QSet< T > &  other)
inline

Definition at line 204 of file qset.h.

204 { intersect(other); return *this; }
QSet< T > & intersect(const QSet< T > &other)
Definition: qset.h:256
QSet<T>& operator&= ( const T &  value)
inline

Definition at line 205 of file qset.h.

206  { QSet<T> result; if (contains(value)) result.insert(value); return (*this = result); }
bool contains(const T &value) const
Definition: qset.h:91
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator insert(const T &value)
Definition: qset.h:179
QSet<T>& operator+= ( const QSet< T > &  other)
inline

Definition at line 207 of file qset.h.

207 { unite(other); return *this; }
QSet< T > & unite(const QSet< T > &other)
Definition: qset.h:244
QSet<T>& operator+= ( const T &  value)
inline

Definition at line 208 of file qset.h.

208 { insert(value); return *this; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
const_iterator insert(const T &value)
Definition: qset.h:179
QSet<T>& operator-= ( const QSet< T > &  other)
inline

Definition at line 209 of file qset.h.

209 { subtract(other); return *this; }
QSet< T > & subtract(const QSet< T > &other)
Definition: qset.h:270
QSet<T>& operator-= ( const T &  value)
inline

Definition at line 210 of file qset.h.

210 { remove(value); return *this; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
QSet<T> operator| ( const QSet< T > &  other) const
inline

Definition at line 211 of file qset.h.

212  { QSet<T> result = *this; result |= other; return result; }
QSet<T> operator& ( const QSet< T > &  other) const
inline

Definition at line 213 of file qset.h.

214  { QSet<T> result = *this; result &= other; return result; }
QSet<T> operator+ ( const QSet< T > &  other) const
inline

Definition at line 215 of file qset.h.

216  { QSet<T> result = *this; result += other; return result; }
QSet<T> operator- ( const QSet< T > &  other) const
inline

Definition at line 217 of file qset.h.

218  { QSet<T> result = *this; result -= other; return result; }
QSet<T> operator| ( const QSet< T > &  other)
inline

Definition at line 221 of file qset.h.

222  { QSet<T> result = *this; result |= other; return result; }
QSet<T> operator& ( const QSet< T > &  other)
inline

Definition at line 223 of file qset.h.

224  { QSet<T> result = *this; result &= other; return result; }
QSet<T> operator+ ( const QSet< T > &  other)
inline

Definition at line 225 of file qset.h.

226  { QSet<T> result = *this; result += other; return result; }
QSet<T> operator- ( const QSet< T > &  other)
inline

Definition at line 227 of file qset.h.

228  { QSet<T> result = *this; result -= other; return result; }
Q_OUTOFLINE_TEMPLATE QList< T > toList ( ) const

Definition at line 296 of file qset.h.

297 {
298  QList<T> result;
299  result.reserve(size());
300  typename QSet<T>::const_iterator i = constBegin();
301  while (i != constEnd()) {
302  result.append(*i);
303  ++i;
304  }
305  return result;
306 }
void reserve(int size)
Definition: qlist.h:496
int size() const
Definition: qset.h:75
const_iterator constEnd() const
Definition: qset.h:171
void append(const T &t)
Definition: qlist.h:507
const_iterator constBegin() const
Definition: qset.h:168
QList<T> values ( ) const
inline

Definition at line 232 of file qset.h.

232 { return toList(); }
QList< T > toList() const
Definition: qset.h:296
QSet< T > fromList ( const QList< T > &  list)
static

Definition at line 319 of file qset.h.

320 {
321  return list.toSet();
322 }
QSet< T > toSet() const
Definition: qset.h:309

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