CMS 3D CMS Logo

PStrings Class Reference

A wrapper for a vector<string> that guarantees no repeats. More...

#include <CondFormats/IdealGeometryObjects/interface/PersistentDDDObjects.h>

List of all members.

Public Member Functions

int operator() (const std::string &str)

Public Attributes

std::vector< std::string > pStrings


Detailed Description

A wrapper for a vector<string> that guarantees no repeats.

This class also returns the index in the vector so that the caller gets back the existing string or the newly inserted index (for this unique string).

FIX: Maybe the overloading of the operator() was a bad way to go...

Definition at line 31 of file PersistentDDDObjects.h.


Member Function Documentation

int PStrings::operator() ( const std::string &  str  )  [inline]

Definition at line 35 of file PersistentDDDObjects.h.

References i, and pStrings.

00035                                         {
00036     // insert to vector for now.
00037     // VERY SLOW string comparison based inserts... could be a trie someday?
00038     //    std::cout << "try to insert " << str << std::endl;
00039     size_t i = 0;
00040     while (  i < pStrings.size() && pStrings[i] != str ) {
00041       //      std::cout << pStrings[i] << std::endl;
00042       ++i;
00043     }
00044     if ( i < pStrings.size() && pStrings[i] == str ) {
00045       return i;
00046     }
00047     pStrings.push_back(str);
00048     return pStrings.size() - 1;
00049 /*     std::vector<std::string>::const_iterator it = std::find(pStrings.begin(), pStrings.end()); */
00050 /*     if ( it == pStrings.end() ) { */
00051 /*       pStrings.push_back(str); */
00052 /*       return pStrings.back(); */
00053 /*     } */
00054 /*     return *it; */
00055   }


Member Data Documentation

std::vector<std::string> PStrings::pStrings

Definition at line 57 of file PersistentDDDObjects.h.

Referenced by WriteOneGeometryFromXML::beginJob(), and operator()().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:30:22 2009 for CMSSW by  doxygen 1.5.4