Helios++
Helios software for LiDAR simulations
MinDragger.hpp
1 #ifndef _SURFACEINSPECTOR_UTIL_DRAGGERS_MIN_DRAGGER_HPP_
2 #define _SURFACEINSPECTOR_UTIL_DRAGGERS_MIN_DRAGGER_HPP_
3 
4 #include <surfaceinspector/util/draggers/OptimizationDragger.hpp>
5 
7 
8 namespace SurfaceInspector { namespace util { namespace draggers{
18 template <typename E> class MinDragger : public OptimizationDragger<E>{
19 protected:
20  // *** ATTRIBUTES *** //
21  // ******************** //
25  vector<E> x;
31  size_t stopSize;
39  bool initialized = false;
43  size_t a = 0;
47  size_t b = 0;
51  size_t c = 0;
52 
53 public:
54  // *** CONSTRUCTION / DESTRUCTION *** //
55  // ************************************ //
61  MinDragger(vector<E> x) : x(x), stopSize(x.size()-1), initialized(false){};
62 
66  virtual ~MinDragger() {};
67 
68 protected:
69  // *** INITIALIZATION *** //
70  // ************************ //
77  virtual void initialize();
78 
79 protected:
80  // *** OPTIMIZATION DRAGGER METHODS *** //
81  // ************************************** //
87  inline E pick() override {return x[c];}
97  void update() override;
98 
99  // *** INNER METHODS *** //
100  // *********************** //
112  virtual void partialSort();
113 public:
114  // *** DRAGGER METHODS *** //
115  // ************************* //
119  bool hasNext() override {return c < stopSize;}
120 };
121 
122 }}}
123 
124 #include <surfaceinspector/util/draggers/MinDragger.tpp>
125 #endif
Dragger interface provide methods to drag elements from a given collection following a certain order....
Definition: IDragger.hpp:21
Min dragger drags the minimum element. The first time next is called the minimum element is returned,...
Definition: MinDragger.hpp:18
bool hasNext() override
Definition: MinDragger.hpp:119
size_t stopSize
The number of elements in the collection x, minus 1.
Definition: MinDragger.hpp:31
size_t b
The end index.
Definition: MinDragger.hpp:47
virtual void partialSort()
Do a partial sort.
vector< E > x
The collection (as vector) to min-drag from.
Definition: MinDragger.hpp:25
virtual void initialize()
Initialize the minimum dragger to the initial status.
size_t a
The start index.
Definition: MinDragger.hpp:43
size_t c
The current index.
Definition: MinDragger.hpp:51
void update() override
Update the minimum dragger status which basically means updating and values while partially sorting...
virtual ~MinDragger()
Default destructor.
Definition: MinDragger.hpp:66
bool initialized
Specify if the min dragger has been initialized (true) or nor (false).
Definition: MinDragger.hpp:39
MinDragger(vector< E > x)
Build a minimum dragger.
Definition: MinDragger.hpp:61
E pick() override
Pick the minimum element inside indices.
Definition: MinDragger.hpp:87
Optimization dragger interface provide methods expanding dragger definition to become a optimization ...
Definition: OptimizationDragger.hpp:25