cgma
OrderedMap< X, Y > Class Template Reference

#include <OrderedMap.hpp>

List of all members.

Public Member Functions

 OrderedMap (void)
bool find (X key, Y *data=NULL) const
bool insert (X new_key, Y new_data)
void erase (X key_to_erase)
void erase_iter (int iter_to_erase)
X first (int iter) const
Y second (int iter) const
bool empty (void) const
int size (void) const
void clean_out (void)
OrderedMap< X, Y > & operator= (const OrderedMap< X, Y > &from)
Y operator[] (X key) const

Private Attributes

DLIList< XmList1
std::map< X, YmMap

Detailed Description

template<class X, class Y>
class OrderedMap< X, Y >

Definition at line 20 of file OrderedMap.hpp.


Constructor & Destructor Documentation

template<class X, class Y>
OrderedMap< X, Y >::OrderedMap ( void  ) [inline]

Definition at line 28 of file OrderedMap.hpp.

{};

Member Function Documentation

template<class X, class Y>
void OrderedMap< X, Y >::clean_out ( void  ) [inline]

Definition at line 94 of file OrderedMap.hpp.

    {
        mList1.clean_out();
        mMap.clear();
    };
template<class X, class Y>
bool OrderedMap< X, Y >::empty ( void  ) const [inline]

Definition at line 91 of file OrderedMap.hpp.

{ return ( mList1.size() == 0 ? CUBIT_TRUE : CUBIT_FALSE ); };
template<class X, class Y>
void OrderedMap< X, Y >::erase ( X  key_to_erase) [inline]

Definition at line 58 of file OrderedMap.hpp.

    {
        typename std::map<X,Y>::iterator iter = mMap.find( key_to_erase );
        if ( iter != mMap.end() )
        {
            mMap.erase( iter );
            mList1.remove_all_with_value( key_to_erase );
        }
    };
template<class X, class Y>
void OrderedMap< X, Y >::erase_iter ( int  iter_to_erase) [inline]

Definition at line 68 of file OrderedMap.hpp.

    {
        X key_to_erase = mList1[iter_to_erase];
        typename std::map<X,Y>::iterator iter = mMap.find( key_to_erase );
        if ( iter != mMap.end() )
        {
            mMap.erase( iter );
            mList1.remove_all_with_value( key_to_erase );
        }
    };
template<class X, class Y>
bool OrderedMap< X, Y >::find ( X  key,
Y data = NULL 
) const [inline]

Definition at line 30 of file OrderedMap.hpp.

    {
        typename std::map<X,Y>::const_iterator iter = mMap.find( key );
        if ( iter == mMap.end() )
        {
            return CUBIT_FALSE;
        }
        if ( data )
        {
            *data = iter->second;
        }
        return CUBIT_TRUE;
    };
template<class X, class Y>
X OrderedMap< X, Y >::first ( int  iter) const [inline]

Definition at line 79 of file OrderedMap.hpp.

    {
        return mList1[iter];
    }
template<class X, class Y>
bool OrderedMap< X, Y >::insert ( X  new_key,
Y  new_data 
) [inline]

Definition at line 46 of file OrderedMap.hpp.

    {
        if ( !find( new_key ) )
        {
            mList1.append( new_key );
            mMap.insert( std::pair<X,Y>( new_key, new_data ) );
            return CUBIT_TRUE;
        }
        return CUBIT_FALSE;
    };
template<class X, class Y>
OrderedMap<X,Y>& OrderedMap< X, Y >::operator= ( const OrderedMap< X, Y > &  from) [inline]

Definition at line 100 of file OrderedMap.hpp.

    {
        clean_out();
        for ( int i = 0; i < from.size(); i++ )
        {
            X key = from.first( i );
            Y data = from.second( i );
            this->insert( key, data );
        }
        return *this;
    };
template<class X, class Y>
Y OrderedMap< X, Y >::operator[] ( X  key) const [inline]

Definition at line 112 of file OrderedMap.hpp.

    {
        Y data;
        bool stat = find( key, &data );
        //assert(stat);
        if(!stat)
          throw std::invalid_argument("The key specified was not found");
        return data;
    };
template<class X, class Y>
Y OrderedMap< X, Y >::second ( int  iter) const [inline]

Definition at line 83 of file OrderedMap.hpp.

    {
        Y data;
        bool stat = find( mList1[iter], &data );
        assert(stat);
        return data;
    }
template<class X, class Y>
int OrderedMap< X, Y >::size ( void  ) const [inline]

Definition at line 92 of file OrderedMap.hpp.

{ return mList1.size(); };

Member Data Documentation

template<class X, class Y>
DLIList<X> OrderedMap< X, Y >::mList1 [private]

Definition at line 23 of file OrderedMap.hpp.

template<class X, class Y>
std::map<X,Y> OrderedMap< X, Y >::mMap [private]

Definition at line 24 of file OrderedMap.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines