// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * 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. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // File name: RadmonTLabelledCollection.icc // Creation date: Sep 2005 // Main author: Riccardo Capra // // Id: $Id: RadmonTLabelledCollection.icc,v 1.6 2006/06/29 16:14:31 gunter Exp $ // Tag: $Name: $ // #ifndef RADMONTLABELLEDCOLLECTION_HH #error "RadmonTLabelledCollection.icc cannot be included directly. Please use RadmonTLabelledCollection.hh" #else /* RADMONTLABELLEDCOLLECTION_HH */ template RadmonTLabelledCollection :: RadmonTLabelledCollection() { } template RadmonTLabelledCollection :: RadmonTLabelledCollection(const RadmonTLabelledCollection & copy) { collection=copy.collection; } template RadmonTLabelledCollection :: ~RadmonTLabelledCollection() { } template RadmonTLabelledCollection & RadmonTLabelledCollection :: operator=(const RadmonTLabelledCollection & copy) { collection=copy.collection; return (*this); } template G4int RadmonTLabelledCollection :: GetNItems() const { return collection.size(); } template G4bool RadmonTLabelledCollection :: Empty() const { return collection.empty(); } template G4bool RadmonTLabelledCollection :: ExistsItemByLabel(const G4String & label) const { size_t i(collection.size()); while (i>0) { i--; if (collection[i].GetLabel()==label) return true; } return false; } template G4int RadmonTLabelledCollection :: MultiplicityItemByLabel(const G4String & label) const { G4int count(0); size_t i(collection.size()); while (i>0) { i--; if (collection[i].GetLabel()==label) count++; } return count; } template const LabelledObject & RadmonTLabelledCollection :: GetItem(G4int index) const { return collection[index]; } template LabelledObject & RadmonTLabelledCollection :: GetItem(G4int index) { return collection[index]; } template const LabelledObject & RadmonTLabelledCollection :: FindItemByLabel(const G4String & label, G4int count) const { return const_cast(this)->FindItemByLabel(label, count); } template LabelledObject & RadmonTLabelledCollection :: FindItemByLabel(const G4String & label, G4int count) { typename Collection::iterator i(collection.begin()); typename Collection::iterator const end(collection.end()); while (iGetLabel()==label) { if (count==0) return (*i); count--; } i++; } G4String text("RadmonTLabelledCollection::FindItemByLabel: Label \""); text+=label; text+="\" not found."; G4Exception(text); return collection.front(); } template LabelledObject & RadmonTLabelledCollection :: InsertItemAfter(G4int index) { return InsertBefore(index+1); } template LabelledObject & RadmonTLabelledCollection :: InsertItemBefore(G4int index) { typename Collection::iterator i(collection.begin()); i+=index; collection.insert(i, LabelledObject()); return collection[index]; } template LabelledObject & RadmonTLabelledCollection :: AppendItem(void) { collection.push_back(LabelledObject()); return collection.back(); } template LabelledObject & RadmonTLabelledCollection :: PrependItem(void) { collection.insert(collection.begin(), LabelledObject()); return collection.front(); } template void RadmonTLabelledCollection :: RemoveItemByLabel(const G4String & label, G4int count) { typename Collection::iterator i(collection.begin()); typename Collection::iterator const end(collection.end()); while (iGetLabel()==label) { if (count==0) { collection.erase(i); return; } count--; } i++; } } template void RadmonTLabelledCollection :: RemoveItemsByLabel(const G4String & label) { typename Collection::iterator i(collection.begin()); typename Collection::iterator const end(collection.end()); while (iGetLabel()==label) i=collection.erase(i); else i++; } } template void RadmonTLabelledCollection :: RemoveItem(G4int index) { typename Collection::iterator i(collection.begin()); i+=index; collection.erase(i); } template void RadmonTLabelledCollection :: RemoveItemsByRange(G4int first, G4int last) { typename Collection::iterator i(collection.begin()); typename Collection::iterator j(i); i+=first; j+=last; collection.erase(i, j); } template void RadmonTLabelledCollection :: RemoveAllItems() { collection.clear(); } #endif /* RADMONTLABELLEDCOLLECTION_HH */