Back to index

salome-gui  6.5.0
Public Types | Public Member Functions | Private Attributes | Friends
IMap< Key, Value > Class Template Reference

Indexed map template class. More...

#include <QtxMap.h>

List of all members.

Public Types

typedef IMapIterator< Key, Value > Iterator
typedef IMapConstIterator< Key,
Value > 
ConstIterator

Public Member Functions

 IMap ()
 IMap (const IMap &m)
IMapoperator= (const IMap &m)
int count () const
int size () const
bool empty () const
bool isEmpty () const
void clear ()
QList< Key > keys () const
QList< Value > values () const
bool contains (const Key &key) const
Iterator begin ()
Iterator end ()
ConstIterator begin () const
ConstIterator end () const
Iterator insert (const Key &key, const Value &value, bool overwrite=true)
Iterator replace (const Key &key, const Value &value)
int index (const Key &key) const
Iterator at (const int index)
ConstIterator at (const int index) const
Key & key (const int index)
Value value (const int index)
Value operator[] (const Key &key)
const Value operator[] (const Key &key) const
void erase (Iterator it)
void erase (const Key &key)
void erase (const int index)
void remove (Iterator it)
void remove (const Key &key)
void remove (const int index)

Private Attributes

QList< Key > myKeys
QMap< Key, Value > myData
Key dummyKey
Value dummyValue

Friends

class IMapIterator< Key, Value >
class IMapConstIterator< Key, Value >

Detailed Description

template<class Key, class Value>
class IMap< Key, Value >

Indexed map template class.

Definition at line 33 of file QtxMap.h.


Member Typedef Documentation

template<class Key, class Value>
typedef IMapConstIterator<Key,Value> IMap< Key, Value >::ConstIterator

Definition at line 37 of file QtxMap.h.

template<class Key, class Value>
typedef IMapIterator<Key,Value> IMap< Key, Value >::Iterator

Definition at line 36 of file QtxMap.h.


Constructor & Destructor Documentation

template<class Key, class Value>
IMap< Key, Value >::IMap ( ) [inline]

Definition at line 40 of file QtxMap.h.

{}
template<class Key, class Value>
IMap< Key, Value >::IMap ( const IMap< Key, Value > &  m) [inline]

Definition at line 41 of file QtxMap.h.

: myKeys( m.myKeys ), myData( m.myData ) {}

Member Function Documentation

template<class Key, class Value>
Iterator IMap< Key, Value >::at ( const int  index) [inline]

Definition at line 81 of file QtxMap.h.

{ return Iterator( this, index );      }
template<class Key, class Value>
ConstIterator IMap< Key, Value >::at ( const int  index) const [inline]

Definition at line 82 of file QtxMap.h.

{ return ConstIterator( this, index ); }
template<class Key, class Value>
Iterator IMap< Key, Value >::begin ( ) [inline]

Definition at line 55 of file QtxMap.h.

{ return Iterator( this );               }
template<class Key, class Value>
ConstIterator IMap< Key, Value >::begin ( ) const [inline]

Definition at line 57 of file QtxMap.h.

{ return ConstIterator( this );          }
template<class Key, class Value>
void IMap< Key, Value >::clear ( ) [inline]

Definition at line 49 of file QtxMap.h.

{ myKeys.clear(); myData.clear(); }
template<class Key, class Value>
bool IMap< Key, Value >::contains ( const Key &  key) const [inline]

Definition at line 53 of file QtxMap.h.

{ return myData.contains( key ); }
template<class Key, class Value>
int IMap< Key, Value >::count ( ) const [inline]

Definition at line 44 of file QtxMap.h.

{ return myData.count(); }

Here is the caller graph for this function:

template<class Key, class Value>
bool IMap< Key, Value >::empty ( ) const [inline]

Definition at line 46 of file QtxMap.h.

{ return myData.empty(); }
template<class Key, class Value>
Iterator IMap< Key, Value >::end ( ) [inline]

Definition at line 56 of file QtxMap.h.

{ return Iterator( this, count() );      }

Here is the call graph for this function:

template<class Key, class Value>
ConstIterator IMap< Key, Value >::end ( ) const [inline]

Definition at line 58 of file QtxMap.h.

{ return ConstIterator( this, count() ); }

Here is the call graph for this function:

template<class Key, class Value>
void IMap< Key, Value >::erase ( Iterator  it) [inline]

Definition at line 112 of file QtxMap.h.

{ remove( it );    }
template<class Key, class Value>
void IMap< Key, Value >::erase ( const Key &  key) [inline]

Definition at line 113 of file QtxMap.h.

{ remove( key );   }

Here is the call graph for this function:

template<class Key, class Value>
void IMap< Key, Value >::erase ( const int  index) [inline]

Definition at line 114 of file QtxMap.h.

{ remove( index ); }

Here is the call graph for this function:

template<class Key, class Value>
int IMap< Key, Value >::index ( const Key &  key) const [inline]

Definition at line 80 of file QtxMap.h.

{ return myKeys.indexOf( key );      }

Here is the caller graph for this function:

template<class Key, class Value>
Iterator IMap< Key, Value >::insert ( const Key &  key,
const Value &  value,
bool  overwrite = true 
) [inline]

Definition at line 60 of file QtxMap.h.

  { 
    if ( myData.find( key ) == myData.end() || overwrite )
    {
      if ( myData.find( key ) != myData.end() && overwrite )
        myKeys.removeAt( myKeys.indexOf( key ) );
      myKeys.append( key );
      myData[key] = value;
    }
    return Iterator( this, index( key ) );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Key, class Value>
bool IMap< Key, Value >::isEmpty ( ) const [inline]

Definition at line 47 of file QtxMap.h.

{ return myData.empty(); }
template<class Key, class Value>
Key& IMap< Key, Value >::key ( const int  index) [inline]

Definition at line 84 of file QtxMap.h.

  {
    if ( index < 0 || index >= (int)myKeys.count() ) 
      return dummyKey;
    return myKeys[index];
  }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Key, class Value>
QList<Key> IMap< Key, Value >::keys ( ) const [inline]

Definition at line 51 of file QtxMap.h.

{ return myKeys; }
template<class Key, class Value>
IMap& IMap< Key, Value >::operator= ( const IMap< Key, Value > &  m) [inline]

Definition at line 42 of file QtxMap.h.

{ myKeys = m.myKeys; myData = m.myData; return *this; }
template<class Key, class Value>
Value IMap< Key, Value >::operator[] ( const Key &  key) [inline]

Definition at line 98 of file QtxMap.h.

  {
    if ( myData.find( key ) == myData.end() )
      insert( key, Value() );
    return myData[ key ];
  }

Here is the call graph for this function:

template<class Key, class Value>
const Value IMap< Key, Value >::operator[] ( const Key &  key) const [inline]

Definition at line 105 of file QtxMap.h.

  {
    if ( myData.find( key ) == myData.end() )
      return dummyValue;
    return myData[key];
  }

Here is the call graph for this function:

template<class Key, class Value>
void IMap< Key, Value >::remove ( Iterator  it) [inline]

Definition at line 115 of file QtxMap.h.

{ if ( it.myMap != this ) return; remove( it.myIndex ); }
template<class Key, class Value>
void IMap< Key, Value >::remove ( const Key &  key) [inline]

Definition at line 116 of file QtxMap.h.

{ remove( index( key ) ); }

Here is the call graph for this function:

template<class Key, class Value>
void IMap< Key, Value >::remove ( const int  index) [inline]

Definition at line 117 of file QtxMap.h.

  {
    if ( index >= 0 && index < (int)myKeys.count() )
    {
      myData.remove( myKeys[index] );
      myKeys.removeAt( index );
    }
  }

Here is the call graph for this function:

template<class Key, class Value>
Iterator IMap< Key, Value >::replace ( const Key &  key,
const Value &  value 
) [inline]

Definition at line 72 of file QtxMap.h.

  { 
    if ( myData.find( key ) == myData.end() )
      myKeys.append( key );
    myData[ key ] = value;
    return Iterator( this, index( key ) );
  }

Here is the call graph for this function:

template<class Key, class Value>
int IMap< Key, Value >::size ( ) const [inline]

Definition at line 45 of file QtxMap.h.

{ return myData.count(); }
template<class Key, class Value>
Value IMap< Key, Value >::value ( const int  index) [inline]

Definition at line 91 of file QtxMap.h.

  {
    if ( index < 0 || index >= (int)myKeys.count() ) 
      return dummyValue;
    return myData[ myKeys[index] ];
  }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class Key, class Value>
QList<Value> IMap< Key, Value >::values ( ) const [inline]

Definition at line 52 of file QtxMap.h.

{ QList<Value> l; for ( int i = 0; i < count(); i++ ) l.append( value( i ) ); return l; }

Here is the call graph for this function:


Friends And Related Function Documentation

template<class Key, class Value>
friend class IMapConstIterator< Key, Value > [friend]

Definition at line 133 of file QtxMap.h.

template<class Key, class Value>
friend class IMapIterator< Key, Value > [friend]

Definition at line 132 of file QtxMap.h.


Member Data Documentation

template<class Key, class Value>
Key IMap< Key, Value >::dummyKey [private]

Definition at line 129 of file QtxMap.h.

template<class Key, class Value>
Value IMap< Key, Value >::dummyValue [private]

Definition at line 130 of file QtxMap.h.

template<class Key, class Value>
QMap<Key,Value> IMap< Key, Value >::myData [private]

Definition at line 128 of file QtxMap.h.

template<class Key, class Value>
QList<Key> IMap< Key, Value >::myKeys [private]

Definition at line 127 of file QtxMap.h.


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