RE: [ROOT] obtaining position of TIterator

From: Faine, Valeri (fine@bnl.gov)
Date: Mon Jan 27 2003 - 00:35:42 MET


Hello Andrzej,

It is possible via TObjLink class

http://atlassw1.phy.bnl.gov/cgi-bin/cvsweb.cgi/offline/Database/AthenaRo
ot/RootKernel/RootKernel/TLISTiterator.h?rev=1.1&content-type=text/x-cvs
web-markup 

  Hope this helps, Valeri 

// $Id: TLISTiterator.h,v 1.1 2002/06/12 17:36:44 fine Exp $
// Author: Valery Fine(fine@bnl.gov)   01/06/2002
//
#ifndef ATLAS_TList_iterator
#define ATLAS_TList_iterator
#include "TList.h"

namespace TLIST {
class iterator {
    protected:
       TObjLink *fLink;
    public:        
       iterator(TObjLink *link=0) : fLink(link){}
       iterator(TList *list) : fLink(list ? list->FirstLink() : 0 ){}
       iterator(const iterator &iter) : fLink(iter.fLink) {}
       iterator(const TObjLink &link) : fLink((TObjLink *)&link) {}
       virtual ~iterator(){}
       TObject *Current() const;
       TObject *Current();
       void Next();
       void Prev();
       void operator++()    {Next();      }
       void operator++(int) {operator++();}
       void operator--()    {Prev();      }
       void operator--(int) {operator--();}
       TObject *operator*();
       TObject *operator*() const;
       Bool_t operator==(const iterator &iter) const;
       Bool_t operator!=(const iterator &iter) const;
       Bool_t operator==(const TObject &obj) const;
       Bool_t operator!=(const TObject &obj) const;
};

inline  TObject *iterator::Current() const 
{   return fLink ? fLink->GetObject():0; }

inline TObject *iterator::Current()
{return ((const iterator*)this)->Current();}

inline void iterator::Next() {  if(fLink) fLink = fLink->Next();  }

inline void iterator::Prev() {  if(fLink) fLink = fLink->Prev(); }

inline TObject *iterator::operator*() {   return Current(); }

inline TObject *iterator::operator*() const { return Current(); }

inline Bool_t iterator::operator==(const iterator &iter) const 
{   return fLink == iter.fLink; }

inline Bool_t iterator::operator!=(const iterator &iter) const 
{  return !operator==(iter); }

inline Bool_t iterator::operator==(const TObject &obj) const 
{   return (fLink) ? obj.IsEqual(Current()) : kFALSE; }

inline    Bool_t iterator::operator!=(const TObject &obj) const 
{   return !operator==(obj); }

}
#endif




> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of olszewsk@chall.ifj.edu.pl
> Sent: Sunday, January 26, 2003 11:28 AM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] obtaining position of TIterator
> 
> 
>    Hi,
> 
>       I don't see how to obtain current position of TIterator and then
> later set it back to this position. Is it possible?
> 
>    Andrzej.
> 
>
*-----------------------------------------------------------------------
--
> *
>  Dr. Andrzej Olszewski                     High Energy Physics Lab
>  email : andrzej.olszewski@ifj.edu.pl      Institute of Nuclear
Physics
>  tel. +12-48-6333366 (secr.)               ul. Kawiory 26a
>  fax. +12-48-6333884                       30-055 Krakow
>  WWW : http://www.ifj.edu.pl/~olszewsk     Poland
>
*-----------------------------------------------------------------------
--
> *
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET