DGtal  0.9.2
DigitalSetBySTLVector.h
1 
17 #pragma once
18 
35 #if defined(DigitalSetBySTLVector_RECURSES)
36 #error Recursive header files inclusion detected in DigitalSetBySTLVector.h
37 #else // defined(DigitalSetBySTLVector_RECURSES)
38 
39 #define DigitalSetBySTLVector_RECURSES
40 
41 #if !defined DigitalSetBySTLVector_h
42 
43 #define DigitalSetBySTLVector_h
44 
46 // Inclusions
47 #include <iostream>
48 #include <vector>
49 #include <string>
50 #include "DGtal/base/Common.h"
51 #include "DGtal/base/CowPtr.h"
52 #include "DGtal/base/Clone.h"
53 #include "DGtal/base/Alias.h"
54 #include "DGtal/base/ConstAlias.h"
56 
57 namespace DGtal
58 {
59 
61  // template class DigitalSetBySTLVector
79  template <typename TDomain>
81  {
82  public:
83  typedef TDomain Domain;
85  typedef typename Domain::Space Space;
86  typedef typename Domain::Point Point;
87  typedef typename Domain::Size Size;
88  typedef typename std::vector<Point>::const_iterator Iterator;
89  typedef typename std::vector<Point>::const_iterator ConstIterator;
90  typedef typename std::vector<Point>::iterator MutableIterator;
91 
92  // ----------------------- Standard services ------------------------------
93  public:
94 
99 
107 
113 
120 
124  const Domain & domain() const;
125 
130 
131  // ----------------------- Standard Set services --------------------------
132  public:
133 
137  Size size() const;
138 
142  bool empty() const;
143 
150  void insert( const Point & p );
151 
160  template <typename PointInputIterator>
161  void insert( PointInputIterator first, PointInputIterator last );
162 
173  void insertNew( const Point & p );
174 
189  template <typename PointInputIterator>
190  void insertNew( PointInputIterator first, PointInputIterator last );
191 
198  Size erase( const Point & p );
199 
207  void erase( Iterator it );
208 
216  void erase( Iterator first, Iterator last );
217 
222  void clear();
223 
228  ConstIterator find( const Point & p ) const;
229 
234  Iterator find( const Point & p );
235 
239  ConstIterator begin() const;
240 
244  ConstIterator end() const;
245 
249  Iterator begin();
250 
254  Iterator end();
255 
260  DigitalSetBySTLVector<Domain> & operator+=
261  ( const DigitalSetBySTLVector<Domain> & aSet );
262 
263  // ----------------------- Model of concepts::CPointPredicate -----------------------------
264  public:
265 
270  bool operator()( const Point & p ) const;
271 
272  // ----------------------- Other Set services -----------------------------
273  public:
274 
280  template< typename TOutputIterator >
281  void computeComplement(TOutputIterator& ito) const;
282 
289  void assignFromComplement( const DigitalSetBySTLVector<Domain> & other_set );
290 
299  void computeBoundingBox( Point & lower, Point & upper ) const;
300 
301  // ----------------------- Interface --------------------------------------
302  public:
303 
308  void selfDisplay ( std::ostream & out ) const;
309 
314  bool isValid() const;
315 
316  // ------------------------- Protected Datas ------------------------------
317  protected:
318 
324 
328  std::vector<Point> myVector;
329 
330  // ------------------------- Private Datas --------------------------------
331  private:
332 
333 
334 
335  // --------------- CDrawableWithBoard2D realization --------------------
336  public:
337 
341  std::string className() const;
342 
343  public:
344 
345 
346  // ------------------------- Hidden services ------------------------------
347  protected:
348 
354 
355  // ------------------------- Internals ------------------------------------
356  private:
357 
358  }; // end of class DigitalSetBySTLVector
359 
360 
367  template <typename Domain>
368  std::ostream&
369  operator<< ( std::ostream & out,
370  const DigitalSetBySTLVector<Domain> & object );
371 
372 } // namespace DGtal
373 
374 
376 // Includes inline functions.
377 #include "DGtal/kernel/sets/DigitalSetBySTLVector.ih"
378 
379 // //
381 
382 #endif // !defined DigitalSetBySTLVector_h
383 
384 #undef DigitalSetBySTLVector_RECURSES
385 #endif // else defined(DigitalSetBySTLVector_RECURSES)
std::vector< Point >::const_iterator ConstIterator
CowPtr< Domain > domainPointer() const
void insertNew(const Point &p)
bool operator()(const Point &p) const
ConstIterator end() const
void selfDisplay(std::ostream &out) const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
void insert(const Point &p)
DigitalSetBySTLVector< Domain > Self
std::string className() const
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
ConstIterator find(const Point &p) const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ConstIterator begin() const
DigitalSetBySTLVector & operator=(const DigitalSetBySTLVector &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
void computeComplement(TOutputIterator &ito) const
void computeBoundingBox(Point &lower, Point &upper) const
Aim: Realizes the concept CDigitalSet by using the STL container std::vector.
Size erase(const Point &p)
std::vector< Point >::const_iterator Iterator
void assignFromComplement(const DigitalSetBySTLVector< Domain > &other_set)
std::vector< Point >::iterator MutableIterator
const Domain & domain() const