Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QMap< Key, T > Class Template Reference

#include <qmap.h>

Public Types

typedef QMapIterator< Key, T > Iterator
 
typedef QMapConstIterator< Key, T > ConstIterator
 
typedef T ValueType
 
typedef QMapPrivate< Key, T > Priv
 

Public Member Functions

 QMap ()
 
 QMap (const QMap< Key, T > &m)
 
 ~QMap ()
 
QMap< Key, T > & operator= (const QMap< Key, T > &m)
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 
Iterator find (const Key &k)
 
ConstIterator find (const Key &k) const
 
T & operator[] (const Key &k)
 
const T & operator[] (const Key &k) const
 
bool contains (const Key &k) const
 
uint count () const
 
bool isEmpty () const
 
Iterator insert (const Key &key, const T &value)
 
void remove (Iterator it)
 
void remove (const Key &k)
 
Iterator replace (const Key &k, const T &v)
 
void clear ()
 

Protected Member Functions

void detach ()
 

Protected Attributes

Privsh
 

Detailed Description

template<class Key, class T>
class QMap< Key, T >

Definition at line 501 of file qmap.h.

Member Typedef Documentation

template<class Key, class T>
typedef QMapConstIterator< Key, T > QMap< Key, T >::ConstIterator

Definition at line 508 of file qmap.h.

template<class Key, class T>
typedef QMapIterator< Key, T > QMap< Key, T >::Iterator

Typedefs

Definition at line 507 of file qmap.h.

template<class Key, class T>
typedef QMapPrivate< Key, T > QMap< Key, T >::Priv

Definition at line 510 of file qmap.h.

template<class Key, class T>
typedef T QMap< Key, T >::ValueType

Definition at line 509 of file qmap.h.

Constructor & Destructor Documentation

template<class Key, class T>
QMap< Key, T >::QMap ( )
inline

API

Definition at line 515 of file qmap.h.

515 { sh = new QMapPrivate< Key, T >; }
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
QMap< Key, T >::QMap ( const QMap< Key, T > &  m)
inline

Definition at line 516 of file qmap.h.

516 { sh = m.sh; sh->ref(); }
void ref()
Definition: qshared.h:49
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
QMap< Key, T >::~QMap ( )
inline

Definition at line 517 of file qmap.h.

517 { if ( sh->deref() ) delete sh; }
bool deref()
Definition: qshared.h:50
Priv * sh
Definition: qmap.h:577

Member Function Documentation

template<class Key, class T>
Iterator QMap< Key, T >::begin ( )
inline

Definition at line 522 of file qmap.h.

522 { detach(); return sh->begin(); }
Iterator begin()
Definition: qmap.h:383
void detach()
Definition: qmap.h:575
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
ConstIterator QMap< Key, T >::begin ( ) const
inline

Definition at line 524 of file qmap.h.

524 { return ((const Priv*)sh)->begin(); }
QMapPrivate< Key, T > Priv
Definition: qmap.h:510
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
void QMap< Key, T >::clear ( )
inline

Definition at line 565 of file qmap.h.

565 { if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new QMapPrivate<Key,T>; } }
bool deref()
Definition: qshared.h:50
uint count
Definition: qshared.h:51
Priv * sh
Definition: qmap.h:577
void clear()
Definition: qmap.h:366
template<class Key, class T>
bool QMap< Key, T >::contains ( const Key &  k) const
inline

Definition at line 537 of file qmap.h.

538  { return find( k ) != end(); }
Iterator end()
Definition: qmap.h:523
Iterator find(const Key &k)
Definition: qmap.h:527
template<class Key, class T>
uint QMap< Key, T >::count ( ) const
inline

Definition at line 541 of file qmap.h.

541 { return sh->node_count; }
int node_count
Definition: qmap.h:306
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
void QMap< Key, T >::detach ( )
inlineprotected

Helpers

Definition at line 575 of file qmap.h.

575 { if ( sh->count > 1 ) { sh->deref(); sh = new QMapPrivate<Key,T>( sh ); } }
bool deref()
Definition: qshared.h:50
uint count
Definition: qshared.h:51
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
Iterator QMap< Key, T >::end ( )
inline

Definition at line 523 of file qmap.h.

523 { detach(); return sh->end(); }
void detach()
Definition: qmap.h:575
Iterator end()
Definition: qmap.h:384
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
ConstIterator QMap< Key, T >::end ( ) const
inline

Definition at line 525 of file qmap.h.

525 { return ((const Priv*)sh)->end(); }
QMapPrivate< Key, T > Priv
Definition: qmap.h:510
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
Iterator QMap< Key, T >::find ( const Key &  k)
inline

Definition at line 527 of file qmap.h.

528  { detach(); return Iterator( sh->find( k ).node ); }
QMapIterator< Key, T > Iterator
Definition: qmap.h:507
ConstIterator find(const Key &k) const
Definition: qmap.h:388
void detach()
Definition: qmap.h:575
QMapNode< K, T > * node
Definition: qmap.h:196
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
ConstIterator QMap< Key, T >::find ( const Key &  k) const
inline

Definition at line 529 of file qmap.h.

530  { return sh->find( k ); }
ConstIterator find(const Key &k) const
Definition: qmap.h:388
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
Iterator QMap< Key, T >::insert ( const Key &  key,
const T &  value 
)
inline

Definition at line 545 of file qmap.h.

545  {
546  detach();
547  Iterator it = sh->insertSingle( key );
548  it.data() = value;
549  return it;
550  }
QMapIterator< Key, T > Iterator
Definition: qmap.h:507
T & data()
Definition: qmap.h:115
def key(type, name=None)
Definition: graph.py:13
void detach()
Definition: qmap.h:575
Priv * sh
Definition: qmap.h:577
Iterator insertSingle(const Key &k)
Definition: qmap.h:437
template<class Key, class T>
bool QMap< Key, T >::isEmpty ( ) const
inline

Definition at line 543 of file qmap.h.

543 { return sh->node_count == 0; }
int node_count
Definition: qmap.h:306
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
QMap<Key,T>& QMap< Key, T >::operator= ( const QMap< Key, T > &  m)
inline

Definition at line 519 of file qmap.h.

520  { m.sh->ref(); if ( sh->deref() ) delete sh; sh = m.sh; return *this; }
bool deref()
Definition: qshared.h:50
void ref()
Definition: qshared.h:49
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
T& QMap< Key, T >::operator[] ( const Key &  k)
inline

Definition at line 531 of file qmap.h.

531  {
532  detach(); QMapNode<Key,T>* p = sh->find( k ).node;
533  if ( p != sh->end().node ) return p->data;
534  return insert( k, T() ).data(); }
QMapNode< K, T > * node
Definition: qmap.h:97
T data
Definition: qmap.h:80
Iterator insert(const Key &key, const T &value)
Definition: qmap.h:545
ConstIterator find(const Key &k) const
Definition: qmap.h:388
void detach()
Definition: qmap.h:575
p
Definition: test.py:223
Iterator end()
Definition: qmap.h:384
QMapNode< K, T > * node
Definition: qmap.h:196
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
const T& QMap< Key, T >::operator[] ( const Key &  k) const
inline

Definition at line 535 of file qmap.h.

536  { return sh->find( k ).data(); }
ConstIterator find(const Key &k) const
Definition: qmap.h:388
Priv * sh
Definition: qmap.h:577
const T & data() const
Definition: qmap.h:214
template<class Key, class T>
void QMap< Key, T >::remove ( Iterator  it)
inline

Definition at line 552 of file qmap.h.

552 { detach(); sh->remove( it ); }
void remove(Iterator it)
Definition: qmap.h:409
void detach()
Definition: qmap.h:575
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
void QMap< Key, T >::remove ( const Key &  k)
inline

Definition at line 553 of file qmap.h.

553  {
554  detach();
555  Iterator it( sh->find( k ).node );
556  if ( it != end() )
557  sh->remove( it );
558  }
Iterator end()
Definition: qmap.h:523
QMapIterator< Key, T > Iterator
Definition: qmap.h:507
void remove(Iterator it)
Definition: qmap.h:409
ConstIterator find(const Key &k) const
Definition: qmap.h:388
void detach()
Definition: qmap.h:575
QMapNode< K, T > * node
Definition: qmap.h:196
Priv * sh
Definition: qmap.h:577
template<class Key, class T>
Iterator QMap< Key, T >::replace ( const Key &  k,
const T &  v 
)
inline

Definition at line 560 of file qmap.h.

560  {
561  remove( k );
562  return insert( k, v );
563  }
Iterator insert(const Key &key, const T &value)
Definition: qmap.h:545

Member Data Documentation

template<class Key, class T>
Priv* QMap< Key, T >::sh
protected

Definition at line 577 of file qmap.h.


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