DGtal  0.9.2
DigitalSetByAssociativeContainer.h
1 
17 #pragma once
18 
39 #if defined(DigitalSetByAssociativeContainer_RECURSES)
40 #error Recursive header files inclusion detected in DigitalSetByAssociativeContainer.h
41 #else // defined(DigitalSetByAssociativeContainer_RECURSES)
42 
43 #define DigitalSetByAssociativeContainer_RECURSES
44 
45 #if !defined DigitalSetByAssociativeContainer_h
46 
47 #define DigitalSetByAssociativeContainer_h
48 
50 // Inclusions
51 #include <iostream>
52 #include <set>
53 #include <string>
54 #include "DGtal/base/Common.h"
55 #include "DGtal/base/CowPtr.h"
56 #include "DGtal/base/Clone.h"
57 #include "DGtal/base/Alias.h"
58 #include "DGtal/base/ConstAlias.h"
59 #include "DGtal/kernel/domains/CDomain.h"
60 #include "DGtal/base/CSTLAssociativeContainer.h"
62 
63 //#include "DGtal/io/Display3D.h"
64 
65 
66 namespace DGtal
67 {
68 
70  // template class DigitalSetByAssociativeContainer
88  template <typename TDomain, typename TContainer >
90  {
91  public:
92 
94  typedef TDomain Domain;
95 
97  typedef TContainer Container;
98 
102  typedef typename Domain::Space Space;
104  typedef typename Domain::Point Point;
106  typedef typename Container::iterator Iterator;
108  typedef typename Container::const_iterator ConstIterator;
110  typedef typename Container::value_type value_type;
112  typedef typename Container::size_type Size;
113 
117  BOOST_STATIC_ASSERT(( boost::is_same<typename Container::key_type, Point>::value ));
118 
119  // ----------------------- Standard services ------------------------------
120  public:
121 
126 
134 
140 
147 
151  const Domain & domain() const;
152 
157 
158  // ----------------------- Standard Set services --------------------------
162  Size size() const;
163 
167  bool empty() const;
168 
175  void insert( const Point & p );
176 
185  template <typename PointInputIterator>
186  void insert( PointInputIterator first, PointInputIterator last );
187 
197  void insertNew( const Point & p );
198 
209  template <typename PointInputIterator>
210  void insertNew( PointInputIterator first, PointInputIterator last );
211 
218  Size erase( const Point & p );
219 
226  void erase( Iterator it );
227 
235  void erase( Iterator first, Iterator last );
236 
241  void clear();
242 
246  ConstIterator find( const Point & p ) const;
247 
252  Iterator find( const Point & p );
253 
257  ConstIterator begin() const;
258 
262  ConstIterator end() const;
263 
267  Iterator begin();
268 
272  Iterator end();
273 
280 
281  // ----------------------- Model of concepts::CPointPredicate -----------------------------
282  public:
283 
288  bool operator()( const Point & p ) const;
289 
290  // ----------------------- Other Set services -----------------------------
291 
297  template< typename TOutputIterator >
298  void computeComplement(TOutputIterator& ito) const;
299 
307 
316  void computeBoundingBox( Point & lower, Point & upper ) const;
317 
318 
319  // ----------------------- Interface --------------------------------------
320 
325  void selfDisplay ( std::ostream & out ) const;
326 
331  bool isValid() const;
332 
333  // ------------------------- Protected Datas ------------------------------
334  protected:
335 
341 
345  Container mySet;
346 
347  // --------------- CDrawableWithBoard2D realization ---------------------
348  public:
349 
353  std::string className() const;
354 
355 
356  // ------------------------- Hidden services ------------------------------
357  protected:
358 
364 
365  }; // end of class DigitalSetByAssociativeContainer
366 
367 
374  template <typename Domain, typename Container>
375  std::ostream&
376  operator<< ( std::ostream & out, const DigitalSetByAssociativeContainer<Domain, Container> & object );
377 
378 } // namespace DGtal
379 
380 
382 // Includes inline functions.
383 #include "DGtal/kernel/sets/DigitalSetByAssociativeContainer.ih"
384 
385 // //
387 
388 #endif // !defined DigitalSetByAssociativeContainer_h
389 
390 #undef DigitalSetByAssociativeContainer_RECURSES
391 #endif // else defined(DigitalSetByAssociativeContainer_RECURSES)
bool operator()(const Point &p) const
ConstIterator find(const Point &p) const
Domain::Point Point
Type of points in the space.
void selfDisplay(std::ostream &out) const
BOOST_STATIC_ASSERT((boost::is_same< typename Container::key_type, Point >::value))
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
void computeBoundingBox(Point &lower, Point &upper) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Defines the concept describing an Associative Container of the STL (https://www.sgi.com/tech/stl/AssociativeContainer.html).
Container::iterator Iterator
Iterator type of the container.
void computeComplement(TOutputIterator &ito) const
Container::value_type value_type
Value type of the container.
DigitalSetByAssociativeContainer< Domain, Container > Self
Self Type.
CowPtr< Domain > domainPointer() const
DigitalSetByAssociativeContainer & operator=(const DigitalSetByAssociativeContainer &other)
Container::const_iterator ConstIterator
ConstIterator type of the container;.
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
Concept checks.
Container::size_type Size
Size type of the container;.
void assignFromComplement(const DigitalSetByAssociativeContainer< Domain, Container > &other_set)