cgma
OrderedSet< X > Class Template Reference

#include <OrderedSet.hpp>

List of all members.

Public Member Functions

 OrderedSet (void)
 OrderedSet (const DLIList< X > list)
 OrderedSet (const std::vector< X > list)
CubitBoolean is_in_list (X item) const
int where_is_item (X item) const
bool replace_item (X old_item, X new_item)
CubitBoolean insert (X new_item)
CubitBoolean append (X new_item)
CubitBoolean prepend (X new_item)
void force_insert (X new_item)
void reverse (void)
void reset (void)
void reserve (int min_size)
X get_and_step (int n=1)
void step (int n=1)
X get () const
const Xoperator[] (int index) const
OrderedSet< X > & operator= (const OrderedSet< X > &from)
OrderedSet< X > & operator= (const DLIList< X > &from)
OrderedSet< X > & operator= (const std::vector< X > &from)
OrderedSet< X > & operator+= (const DLIList< X > &from)
OrderedSet< X > & operator+= (const OrderedSet< X > &from)
OrderedSet< X > & operator+= (const std::vector< X > &from)
OrderedSet< X > & operator+= (X from)
OrderedSet< X > & operator-= (const DLIList< X > &from)
OrderedSet< X > & operator-= (const OrderedSet< X > &from)
OrderedSet< X > & operator-= (const OrderedSet< X > *from)
OrderedSet< X > & operator-= (X from)
OrderedSet< Xoperator& (const OrderedSet< X > other_set) const
OrderedSet< Xoperator| (const OrderedSet< X > other_set) const
CubitBoolean empty (void) const
int size (void) const
X pop (void)
void remove (X item)
void clean_out (void)
void list (DLIList< X > &list) const
const DLIList< X > * list (void) const
const Xlast (void) const
const Xfirst (void) const
const std::vector< X > & as_vector (void) const

Private Attributes

DLIList< XmList
std::set< XmSet

Detailed Description

template<class X>
class OrderedSet< X >

Definition at line 21 of file OrderedSet.hpp.


Constructor & Destructor Documentation

template<class X>
OrderedSet< X >::OrderedSet ( void  ) [inline]

Definition at line 29 of file OrderedSet.hpp.

{};
template<class X>
OrderedSet< X >::OrderedSet ( const DLIList< X list) [inline]

Definition at line 30 of file OrderedSet.hpp.

    {
        int i;
        for ( i = 0; i < list.size(); i++ )
        {
            append( list[i] );
        }
    };
template<class X>
OrderedSet< X >::OrderedSet ( const std::vector< X list) [inline]

Definition at line 39 of file OrderedSet.hpp.

    {
        int i;
        for ( i = 0; i < list.size(); i++ )
        {
            append( list[i] );
        }
    };

Member Function Documentation

template<class X>
CubitBoolean OrderedSet< X >::append ( X  new_item) [inline]

Definition at line 97 of file OrderedSet.hpp.

    {
        return insert( new_item );
    }
template<class X>
const std::vector<X>& OrderedSet< X >::as_vector ( void  ) const [inline]

Definition at line 200 of file OrderedSet.hpp.

{ return mList.as_vector(); };
template<class X>
void OrderedSet< X >::clean_out ( void  ) [inline]

Definition at line 183 of file OrderedSet.hpp.

    {
        mList.clean_out();
        mSet.clear();
    };
template<class X>
CubitBoolean OrderedSet< X >::empty ( void  ) const [inline]

Definition at line 167 of file OrderedSet.hpp.

{ return ( mList.size() == 0 ? CUBIT_TRUE : CUBIT_FALSE ); };
template<class X >
const X & OrderedSet< X >::first ( void  ) const [inline]

Definition at line 212 of file OrderedSet.hpp.

{
    assert( mList.size() > 0 );
    return mList[0];
}
template<class X>
void OrderedSet< X >::force_insert ( X  new_item) [inline]

Definition at line 114 of file OrderedSet.hpp.

    {
        mList.append( new_item );
        mSet.insert( new_item );
    };
template<class X>
X OrderedSet< X >::get ( ) const [inline]

Definition at line 147 of file OrderedSet.hpp.

    {
        return mList.get();
    };
template<class X>
X OrderedSet< X >::get_and_step ( int  n = 1) [inline]

Definition at line 135 of file OrderedSet.hpp.

    {
        X temp = get();
        step( n );
        return temp;
    };
template<class X>
CubitBoolean OrderedSet< X >::insert ( X  new_item) [inline]

Definition at line 86 of file OrderedSet.hpp.

    {
        if ( !is_in_list( new_item ) )
        {
            force_insert( new_item );
            return CUBIT_TRUE;
        }
        return CUBIT_FALSE;
    }
template<class X>
CubitBoolean OrderedSet< X >::is_in_list ( X  item) const [inline]

Definition at line 48 of file OrderedSet.hpp.

    {
        if ( mSet.find( item ) == mSet.end() )
        {
            return CUBIT_FALSE;
        }
        return CUBIT_TRUE;
    };
template<class X >
const X & OrderedSet< X >::last ( void  ) const [inline]

Definition at line 204 of file OrderedSet.hpp.

{
    assert( mList.size() > 0 );
    int index = mList.size()-1;
    return mList[index];
}
template<class X>
void OrderedSet< X >::list ( DLIList< X > &  list) const [inline]

Definition at line 189 of file OrderedSet.hpp.

    {
        list = mList;
    }
template<class X>
const DLIList<X>* OrderedSet< X >::list ( void  ) const [inline]

Definition at line 193 of file OrderedSet.hpp.

    {
        return &mList;
    }
template<class X >
OrderedSet< X > OrderedSet< X >::operator& ( const OrderedSet< X other_set) const [inline]

Definition at line 347 of file OrderedSet.hpp.

{
    OrderedSet<X> tmp;
    for ( int i = 0; i < other_set.size(); i++ )
    {
        if ( this->is_in_list( other_set[i] ) )
        {
            tmp.append( other_set[i] );
        }
    }
    return tmp;
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator+= ( const DLIList< X > &  from) [inline]

Definition at line 281 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list.size(); i++ )
    {
        this->insert( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator+= ( const OrderedSet< X > &  from) [inline]

Definition at line 303 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list.size(); i++ )
    {
        this->insert( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator+= ( const std::vector< X > &  from) [inline]

Definition at line 292 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list.size(); i++ )
    {
        this->insert( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator+= ( X  from) [inline]

Definition at line 267 of file OrderedSet.hpp.

{
    this->insert( from );
    return *this;
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator-= ( const DLIList< X > &  from) [inline]

Definition at line 314 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list.size(); i++ )
    {
        this->remove( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator-= ( const OrderedSet< X > &  from) [inline]

Definition at line 325 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list.size(); i++ )
    {
        this->remove( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator-= ( const OrderedSet< X > *  from) [inline]

Definition at line 336 of file OrderedSet.hpp.

{ 
    int i;
    for ( i = 0; i < list->size(); i++ )
    {
        this->remove( (*list)[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator-= ( X  from) [inline]

Definition at line 274 of file OrderedSet.hpp.

{
    this->remove( from );
    return *this;
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator= ( const OrderedSet< X > &  from) [inline]

Definition at line 225 of file OrderedSet.hpp.

{
    mList.clean_out();
    mSet.clear();
    int i;
    int from_size = from.mList.size();
    for ( i = 0; i < from_size; i++ )
    {
        force_insert( from.mList[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator= ( const DLIList< X > &  from) [inline]

Definition at line 239 of file OrderedSet.hpp.

{ 
    mList.clean_out();
    mSet.clear();
    int i;
    int list_size = list.size();
    for ( i = 0; i < list_size; i++ )
    {
        this->insert( list[i] );
    }
    return *this; 
}
template<class X >
OrderedSet< X > & OrderedSet< X >::operator= ( const std::vector< X > &  from) [inline]

Definition at line 253 of file OrderedSet.hpp.

{ 
    mList.clean_out();
    mSet.clear();
    int i;
    int list_size = list.size();
    for ( i = 0; i < list_size; i++ )
    {
        this->insert( list[i] );
    }
    return *this; 
}
template<class X >
const X & OrderedSet< X >::operator[] ( int  index) const [inline]

Definition at line 219 of file OrderedSet.hpp.

{
    return mList[index];
}
template<class X >
OrderedSet< X > OrderedSet< X >::operator| ( const OrderedSet< X other_set) const [inline]

Definition at line 361 of file OrderedSet.hpp.

{
    OrderedSet<X> tmp = *this;
    tmp += other_set;
    return tmp;
}
template<class X>
X OrderedSet< X >::pop ( void  ) [inline]

Definition at line 169 of file OrderedSet.hpp.

    {
        X item = mList.pop();
        mSet.erase( item );
        return item;
    };
template<class X>
CubitBoolean OrderedSet< X >::prepend ( X  new_item) [inline]

Definition at line 103 of file OrderedSet.hpp.

    {
        if ( !is_in_list( new_item ) )
        {
            mList.insert_first( new_item );
            mSet.insert( new_item );
            return CUBIT_TRUE;
        }
        return CUBIT_FALSE;
    }
template<class X>
void OrderedSet< X >::remove ( X  item) [inline]

Definition at line 175 of file OrderedSet.hpp.

    {
        if ( !is_in_list( item ) )
            return;
        mList.remove_all_with_value( item );
        mSet.erase( item );
    };
template<class X>
bool OrderedSet< X >::replace_item ( X  old_item,
X  new_item 
) [inline]

Definition at line 68 of file OrderedSet.hpp.

    {
        if ( is_in_list( old_item ) )
        {
            for ( int i = 0; i < mList.size(); i++ )
            {
                if ( mList[i] == old_item )
                {
                    mList[i] = new_item;
                    mSet.erase( old_item );
                    mSet.insert( new_item );
                    return true;
                }
            }
        }
        return false;
    };
template<class X>
void OrderedSet< X >::reserve ( int  min_size) [inline]

Definition at line 130 of file OrderedSet.hpp.

    {
      mList.reserve(min_size);
    };
template<class X>
void OrderedSet< X >::reset ( void  ) [inline]

Definition at line 125 of file OrderedSet.hpp.

    {
        mList.reset();
    };
template<class X>
void OrderedSet< X >::reverse ( void  ) [inline]

Definition at line 120 of file OrderedSet.hpp.

    {
        mList.reverse();
    };
template<class X>
int OrderedSet< X >::size ( void  ) const [inline]

Definition at line 168 of file OrderedSet.hpp.

{ return mList.size(); };
template<class X>
void OrderedSet< X >::step ( int  n = 1) [inline]

Definition at line 142 of file OrderedSet.hpp.

    {
        mList.step( n );
    };
template<class X>
int OrderedSet< X >::where_is_item ( X  item) const [inline]

Definition at line 57 of file OrderedSet.hpp.

    {
        CubitBoolean stat = is_in_list( item );
        if ( stat == CUBIT_TRUE )
        {
            return mList.where_is_item( item );
        }
        return -1;
    };

Member Data Documentation

template<class X>
DLIList<X> OrderedSet< X >::mList [private]

Definition at line 24 of file OrderedSet.hpp.

template<class X>
std::set<X> OrderedSet< X >::mSet [private]

Definition at line 25 of file OrderedSet.hpp.


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