Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsMap< index, objectType > Class Template Reference

A map, as a PsType. More...

#include <PsMap.h>

Inheritance diagram for PsMap< index, objectType >:

Inheritance graph
[legend]
Collaboration diagram for PsMap< index, objectType >:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsMap ()
 constructor

virtual ~PsMap ()
 destructor

void addObjectWithIndex (const index &nomObj, objectType refObj)
 easy insertion

objectType getObjectOfIndex (const index &nomObj) const
 easy find

virtual void insertInStream (ostream &=cout) const
 insert the map in an output stream

virtual void extract (istream &=cin)
 extraction of the map from an input stream

virtual void pack (PsOutgoingSynchronisationMessage &out) const
 insert the map in a stream

virtual void unpack (PsIncomingSynchronisationMessage &in)
 extract a map from a stream

virtual PsPolatorNTcreatePolator (void)
 create a polator to conform tp PsType


Detailed Description

template<typename index, typename objectType>
class PsMap< index, objectType >

A map, as a PsType.

Definition at line 36 of file PsMap.h.


Constructor & Destructor Documentation

template<typename index, typename objectType>
PsMap< index, objectType >::PsMap   [inline]
 

constructor

Definition at line 42 of file PsMap.h.

00043 {}

template<typename index, typename objectType>
virtual PsMap< index, objectType >::~PsMap   [inline, virtual]
 

destructor

Definition at line 45 of file PsMap.h.

00046 {}


Member Function Documentation

template<typename index, typename objectType>
void PsMap< index, objectType >::addObjectWithIndex const index &    nomObj,
objectType    refObj
[inline]
 

easy insertion

Definition at line 48 of file PsMap.h.

00050    { 
00051       insert (pair<const index, objectType>(nomObj,refObj)) ;

template<typename index, typename objectType>
virtual PsPolatorNT* PsMap< index, objectType >::createPolator void    [inline, virtual]
 

create a polator to conform tp PsType

Implements PsType.

Definition at line 85 of file PsMap.h.

00087    {
00088       return new PsPolator< PsMap<index,objectType> >() ;

template<typename index, typename objectType>
void PsMap< index, objectType >::extract istream &    = cin [inline, virtual]
 

extraction of the map from an input stream

Implements PsFlowable.

Definition at line 110 of file PsMap.h.

00112 {
00113    int nbElements ;
00114    index ind ;
00115    objectType elem ;
00116    clear () ;
00117    in >> nbElements ;
00118    for (int j = 0 ; j < nbElements ; j ++) {
00119       in >> ind >> elem ;
00120       insert (pair<const index, objectType>(ind,elem)) ;
00121 
00122    }

template<typename index, typename objectType>
objectType PsMap< index, objectType >::getObjectOfIndex const index &    nomObj const [inline]
 

easy find

Definition at line 54 of file PsMap.h.

00056     {
00057 #ifdef _TYPENAMENOTIMPLICIT
00058        typename PsMap<index, objectType>::const_iterator i;
00059 #else
00060        const_iterator i;
00061 #endif
00062        i=find(nomObj);
00063        if (i==end()) 
00064           {
00065              return NULL;
00066           }
00067        else 
00068           {
00069              return (*i).second;
00070           }

template<typename index, typename objectType>
void PsMap< index, objectType >::insertInStream ostream &    = cout const [inline, virtual]
 

insert the map in an output stream

Implements PsFlowable.

Definition at line 94 of file PsMap.h.

00095                                                                           {
00096    out << size () << " " ;
00097 #ifdef _TYPENAMENOTIMPLICIT
00098        typename PsMap<index, objectType>::const_iterator i = begin () ;
00099 #else
00100    const_iterator i = begin () ;
00101 #endif
00102    while (i != end ()) 
00103       {
00104          out << (*i).first <<" "<< (*i).second <<" ";
00105          ++ i  ;
00106       }

template<typename index, typename objectType>
void PsMap< index, objectType >::pack PsOutgoingSynchronisationMessage   out const [virtual]
 

insert the map in a stream

Reimplemented from PsFlowable.

Definition at line 125 of file PsMap.h.

00127 {
00128    out << size ()  ;
00129 #ifdef _TYPENAMENOTIMPLICIT
00130        typename PsMap<index, objectType>::
00131 #endif
00132    const_iterator i = begin () ;
00133    while (i != end ()) {
00134       out << (*i).first << (*i).second ;
00135       ++ i  ;
00136    }

template<typename index, typename objectType>
void PsMap< index, objectType >::unpack PsIncomingSynchronisationMessage   in [virtual]
 

extract a map from a stream

Reimplemented from PsFlowable.

Definition at line 139 of file PsMap.h.

References map< index, objectType, less< index >, STL_ALLOC< pair< const index, objectType > > >::value_type.

00141 {
00142    size_t numberOfElements ;
00143    in>>numberOfElements ;
00144    index ind ;
00145    objectType obj ;
00146    for (int i= 0 ; i < numberOfElements ; ++i)
00147       {
00148          in>>ind>>obj;
00149          insert( PsMap::value_type(ind,obj) ) ;
00150       }


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

Documentation generated on Mon Nov 25 15:26:08 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001