]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Addind methods for iterating
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Nov 2007 11:42:29 +0000 (11:42 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 20 Nov 2007 11:42:29 +0000 (11:42 +0000)
(Christian)

MUON/AliMUONStringIntMap.cxx
MUON/AliMUONStringIntMap.h

index 508356dc600ccb681ce5a6217bbf5fd0a7d89d67..c933730a0ac5a022e0bd7196c36e6f3e957e7e85 100644 (file)
@@ -38,7 +38,8 @@ AliMUONStringIntMap::AliMUONStringIntMap()
  : TObject(),
    fNofItems(0),
    fFirstArray(100),
-   fSecondArray(100)
+   fSecondArray(100),
+   fCurrentIndex(0)
 {
 /// Standard constructor
 
@@ -172,3 +173,30 @@ void AliMUONStringIntMap::Print(const TString& key, ofstream& out) const
         << endl;
   }
 }       
+
+//______________________________________________________________________________
+Bool_t  AliMUONStringIntMap::Next(TString& first, Int_t& second)
+{
+/// Iterator: next method.
+/// Returns false if the iterator reached the end.
+
+  if ( fCurrentIndex >= fNofItems ) return false;
+  
+  TObjString* objString = (TObjString*)fFirstArray.At(fCurrentIndex);
+  first = objString->GetString();
+  
+  second = fSecondArray.At(fCurrentIndex);
+  
+  ++fCurrentIndex;
+  
+  return true;
+}  
+
+//______________________________________________________________________________
+void  AliMUONStringIntMap::ResetItr()
+{
+/// Reset iterator
+  fCurrentIndex = 0;
+}  
index 6bc1142e7e8503e640472c87b250e98846c603fa..1ae2c129637275df73ceeb5ea9e8c002c3594756 100644 (file)
@@ -32,7 +32,11 @@ class AliMUONStringIntMap : public TObject
     virtual void Clear(Option_t* /*option*/ ="");
     virtual void Print(const char* /*option*/ = "") const;
     void Print(const TString& key, ofstream& out) const;
-    
+
+    // Methods for iterating over all elements    
+    Bool_t  Next(TString& first, Int_t& second);
+    void    ResetItr();
+
   protected:
     /// Not implemented
     AliMUONStringIntMap(const AliMUONStringIntMap& rhs);
@@ -44,8 +48,9 @@ class AliMUONStringIntMap : public TObject
     Int_t      fNofItems;    ///< number of items
     TObjArray  fFirstArray;  ///< first item array
     TArrayI    fSecondArray; ///< second item array
-  ClassDef(AliMUONStringIntMap,1)  // motif map
+    Int_t      fCurrentIndex;///< current index
+
+  ClassDef(AliMUONStringIntMap,2)  // motif map
 };    
 
 #endif //ALI_MUON_STRING_INT_MAP_H