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

LbldData.cxx

Go to the documentation of this file.
00001 // $Id: LbldData.cxx,v 1.1.1.1 1999/12/28 01:36:03 burnett Exp $
00002 
00003 #ifdef _MSC_VER
00004 #pragma warning(disable:4786)
00005 #endif
00006 
00007 #include "reconstruction/LbldData.h"
00008 
00009 #include <iomanip>
00010 #include <cassert>
00011 #include <float.h>
00012 
00013 using std::string;
00014 using  std::vector;
00015 using std::pair;
00016 
00017 LbldData::LbldData ()
00018 { 
00019     reserve(100);  // make sure no reallocation
00020 }
00021 
00022 LbldData::~LbldData ()
00023 {}
00024 
00025 
00026 LbldData::iterator LbldData::addElement (const char* c)
00027 {
00028     iterator e = end();
00029     push_back( std::make_pair<string,float>(string(c), 0.) );
00030     assert (&back() == e); // make sure no reallocation
00031     return e;
00032 }
00033 
00034 void LbldData::addData (LbldData::iterator entry, float x)
00035 {
00036     (*entry).second=x;
00037 }
00038 
00039 LbldData::iterator LbldData::addData (char* c, float x)
00040 {
00041     iterator it = (iterator)checkEntry(c);
00042     if( it!=end() ) (*it).second = x;
00043     return it;
00044 }
00045 
00046 float LbldData::getData (LbldData::iterator entry)const
00047 {
00048     return (*entry).second;
00049 }
00050 
00051 float LbldData::getData (const char* name) const
00052 {
00053     const_iterator it = checkEntry(name);
00054     return it!=end() ? (*it).second : FLT_MAX;
00055 }
00056 
00057 LbldData::const_iterator LbldData::checkEntry (const char* c) const
00058 {
00059     for ( const_iterator it = begin(); it != end(); it++ ) {
00060         if( (*it).first == string(c)) return it;
00061     }
00062     return end();
00063  }
00064 
00065 
00066 void LbldData::clear ()
00067 {
00068     for ( iterator it = begin(); it != end(); it++ ) {
00069         (*it).second = 0;
00070     }
00071     return;
00072 }
00073 
00074 
00075 void LbldData::printOn (std::ostream& out)
00076 {
00077     for (iterator it = begin(); it != end(); it++ ) {
00078         out << std::setw(24) << (*it).first << '\t'<< (*it).second<< '\n';
00079     }
00080 }

Generated at Wed Nov 21 12:20:44 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000