Logo ROOT   6.12/07
Reference Guide
RooLinkedListIter.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooLinkedListIter.h,v 1.11 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_LINKED_LIST_ITER
17 #define ROO_LINKED_LIST_ITER
18 
19 #include "Rtypes.h"
20 #include "TIterator.h"
21 #include "RooLinkedList.h"
22 
23 class RooFIter
24 {
25  public:
26  inline RooFIter() : _ptr (0) {}
27  inline RooFIter(const RooLinkedList* list) : _ptr (list->_first) {}
28 
29  inline RooAbsArg *next() {
30  // Return next element in collection
31  if (!_ptr) return 0 ;
32  TObject* arg = _ptr->_arg ;
33  _ptr = _ptr->_next;
34  return (RooAbsArg*) arg ;
35  }
36 
37  private:
38  const RooLinkedListElem* _ptr ; //! Next link element
39 };
40 
41 
42 
43 class RooLinkedListIter : public TIterator {
44 public:
45 
47  // coverity[UNINIT_CTOR]
48  } ;
49 
50 
52  TIterator(), _list(list), _ptr(forward ? _list->_first : _list->_last),
53  _forward(forward)
54  { }
55 
57  TIterator(other), _list(other._list), _ptr(other._ptr),
58  _forward(other._forward)
59  {
60  // Copy constructor
61  }
62 
63  virtual ~RooLinkedListIter() { ; }
64 
65  TIterator& operator=(const TIterator& other) {
66 
67  // Iterator assignment operator
68 
69  if (&other==this) return *this ;
70  const RooLinkedListIter* iter = dynamic_cast<const RooLinkedListIter*>(&other) ;
71  if (iter) {
72  _list = iter->_list ;
73  _ptr = iter->_ptr ;
74  _forward = iter->_forward ;
75  }
76  return *this ;
77  }
78 
79  virtual const TCollection *GetCollection() const {
80  // Dummy
81  return 0 ;
82  }
83 
84  virtual TObject *Next() {
85  // Return next element in collection
86  if (!_ptr) return 0 ;
87  TObject* arg = _ptr->_arg ;
88  _ptr = _forward ? _ptr->_next : _ptr->_prev ;
89  return arg ;
90  }
91 
93  // Return next element in collection
94  if (!_ptr) return 0 ;
95  TObject* arg = _ptr->_arg ;
96  _ptr = _forward ? _ptr->_next : _ptr->_prev ;
97  return arg ;
98  }
99 
100 
101  virtual void Reset() {
102  // Return iterator to first element in collection
103  _ptr = _forward ? _list->_first : _list->_last ;
104  }
105 
106  bool operator!=(const TIterator &aIter) const {
107  const RooLinkedListIter *iter(dynamic_cast<const RooLinkedListIter*>(&aIter));
108  if (iter) return (_ptr != iter->_ptr);
109  return false; // for base class we don't implement a comparison
110  }
111 
112  bool operator!=(const RooLinkedListIter &aIter) const {
113  return (_ptr != aIter._ptr);
114  }
115 
116  virtual TObject *operator*() const {
117  // Return element iterator points to
118  return (_ptr ? _ptr->_arg : nullptr);
119  }
120 
121 protected:
122  const RooLinkedList* _list ; //! Collection iterated over
123  const RooLinkedListElem* _ptr ; //! Next link element
124  Bool_t _forward ; // Iterator direction
125 
126  ClassDef(RooLinkedListIter,2) // Iterator for RooLinkedList container class
127 } ;
128 
129 
130 
131 
132 #endif
const RooLinkedListElem * _ptr
virtual const TCollection * GetCollection() const
RooLinkedListIter(const RooLinkedList *list, Bool_t forward)
virtual ~RooLinkedListIter()
bool Bool_t
Definition: RtypesCore.h:59
RooFIter(const RooLinkedList *list)
const RooLinkedListElem * _ptr
Collection iterated over.
Iterator abstract base class.
Definition: TIterator.h:30
#define ClassDef(name, id)
Definition: Rtypes.h:320
RooLinkedListElem * _next
virtual void Reset()
virtual TObject * Next()
TIterator & operator=(const TIterator &other)
RooLinkedListElem * _prev
Collection abstract base class.
Definition: TCollection.h:63
RooLinkedListIter(const RooLinkedListIter &other)
RooAbsArg * next()
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
virtual TObject * operator*() const
Return current object or nullptr.
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Definition: NeuralNet.icc:545
bool operator!=(const RooLinkedListIter &aIter) const
Mother of all ROOT objects.
Definition: TObject.h:37
const RooLinkedList * _list
RooLinkedListElem is an link element for the RooLinkedList class.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
Bool_t _forward
Next link element.
RooLinkedListIter is the TIterator implementation for RooLinkedList.
bool operator!=(const TIterator &aIter) const
Compare two iterator objects.