Files
geant4/source/particles/management/include/G4ParticleTableIterator.hh
T
2016-06-09 12:11:21 +02:00

79 lines
2.6 KiB
C++

//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ParticleTableIterator.hh,v 1.6 2003/06/16 16:58:07 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// History: first implementation, based on object model of
// 28 Oct 1999, H.Kurashige
// ------------------------------------------------------------
#ifndef G4ParticleTableIterator_h
#define G4ParticleTableIterator_h 1
#include <map>
template < class K, class V > class G4ParticleTableIterator
{
public:
typedef std::map<K, V, std::less<K> > Map;
G4ParticleTableIterator( Map &adict):
it(adict.begin()),
mydict(&adict),
defined(false)
{}
G4bool operator++ ()
{
if(!defined) return false;
it++;
return it!=mydict->end() ? true : false;
}
G4bool operator()()
{
if(defined) {
return operator++();
} else {
defined=true;
it=mydict->begin();
return it!=mydict->end() ? true : false;
}
}
void reset (){defined=false;}
K* key() const { return &((*it).first); }
V value() const { return (*it).second; }
private:
typename Map::iterator it;
Map * mydict;
G4bool defined;
};
#endif