DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DigitalSetBySTLSet.ih
1 
34 
35 #include <cstdlib>
37 
39 // IMPLEMENTATION of inline methods.
41 
43 // ----------------------- Standard services ------------------------------
44 
48 template <typename Domain>
49 inline
51 {
52 }
53 
60 template <typename Domain>
61 inline
63  : myDomain( d ), mySet()
64 {
65 }
66 
71 template <typename Domain>
72 inline
74  : myDomain( other.myDomain ), mySet( other.mySet )
75 {
76 }
77 
83 template <typename Domain>
84 inline
87 {
88  ASSERT( ( myDomain.lowerBound() <= other.myDomain.lowerBound() )
89  && ( myDomain.upperBound() >= other.myDomain.upperBound() )
90  && "This domain should include the domain of the other set in case of assignment." );
91  mySet = other.mySet;
92  return *this;
93 }
94 
95 
99 template <typename Domain>
100 inline
101 const Domain &
103 {
104  return myDomain;
105 }
106 
107 
108 
110 // Interface - public :
111 
112 
116 template <typename Domain>
117 inline
120 {
121  return (unsigned int)mySet.size();
122 }
123 
127 template <typename Domain>
128 inline
129 bool
131 {
132  return mySet.empty();
133 }
134 
135 
142 template <typename Domain>
143 inline
144 void
146 {
147  // ASSERT( myDomain.isInside( p ) );
148  mySet.insert( p );
149 }
150 
151 
160 template <typename Domain>
161 template <typename PointInputIterator>
162 void
163 DGtal::DigitalSetBySTLSet<Domain>::insert( PointInputIterator first, PointInputIterator last )
164 {
165  mySet.insert( first, last );
166 }
167 
168 
178 template <typename Domain>
179 inline
180 void
182 {
183  // ASSERT( myDomain.isInside( p ) );
184  mySet.insert( p );
185 }
186 
197 template <typename Domain>
198 template <typename PointInputIterator>
199 inline
200 void
202 ( PointInputIterator first, PointInputIterator last )
203 {
204  mySet.insert( first, last );
205 }
206 
213 template <typename Domain>
216 {
217  return (unsigned int)mySet.erase( p );
218 }
219 
226 template <typename Domain>
227 inline
228 void
230 {
231  mySet.erase( it );
232 }
233 
238 template <typename Domain>
239 inline
240 void
242 {
243  mySet.clear();
244 }
245 
250 template <typename Domain>
251 inline
254 {
255  return mySet.find( p );
256 }
257 
262 template <typename Domain>
263 inline
266 {
267  return mySet.find( p );
268 }
269 
273 template <typename Domain>
274 inline
277 {
278  return mySet.begin();
279 }
280 
284 template <typename Domain>
285 inline
288 {
289  return mySet.end();
290 }
291 
295 template <typename Domain>
296 inline
299 {
300  return mySet.begin();
301 }
302 
306 template <typename Domain>
307 inline
310 {
311  return mySet.end();
312 }
313 
318 template <typename Domain>
319 inline
323 {
324  if ( this != &aSet )
325  {
326  Iterator it_dst = end();
327  for ( ConstIterator it_src = aSet.begin();
328  it_src != aSet.end();
329  ++it_src )
330  {
331  // Use hint it_dst to go faster.
332  it_dst = mySet.insert( it_dst, *it_src );
333  }
334  }
335  return *this;
336 }
337 
338 
340 // ----------------------- Other Set services -----------------------------
341 
342 
343 template <typename Domain>
344 template <typename TOutputIterator>
345 inline
346 void
348 {
349  typename Domain::ConstIterator itPoint = myDomain.begin();
350  typename Domain::ConstIterator itEnd = myDomain.end();
351  while ( itPoint != itEnd ) {
352  if ( find( *itPoint ) == end() ) {
353  *ito++ = *itPoint;
354  }
355  ++itPoint;
356  }
357 }
358 
365 template <typename Domain>
366 inline
367 void
369 ( const DigitalSetBySTLSet<Domain> & other_set )
370 {
371  clear();
372  typename Domain::ConstIterator itPoint = myDomain.begin();
373  typename Domain::ConstIterator itEnd = myDomain.end();
374  while ( itPoint != itEnd ) {
375  if ( other_set.find( *itPoint ) == other_set.end() ) {
376  insert( *itPoint );
377  }
378  ++itPoint;
379  }
380 }
381 
390 template <typename Domain>
391 inline
392 void
394 ( Point & lower, Point & upper ) const
395 {
396  lower = myDomain.upperBound();
397  upper = myDomain.lowerBound();
398  ConstIterator it = begin();
399  ConstIterator itEnd = end();
400  while ( it != itEnd ) {
401  lower = lower.inf( *it );
402  upper = upper.sup( *it );
403  ++it;
404  }
405 }
406 
408 // Interface - public :
409 
414 template <typename Domain>
415 inline
416 void
418 {
419  out << "[DigitalSetBySTLSet]" << " size=" << size();
420 }
421 
426 template <typename Domain>
427 inline
428 bool
430 {
431  return true;
432 }
433 
434 
435 // --------------- CDrawableWithBoard2D realization -------------------------
436 
445 template<typename Domain>
446 inline
447 std::string
449 {
450  return "DigitalSetBySTLSet";
451 }
452 
454 // Implementation of inline function //
455 
456 template <typename Domain>
457 inline
458 std::ostream &
459 DGtal::operator<< ( std::ostream & out, const DGtal::DigitalSetBySTLSet<Domain> & object )
460 {
461  object.selfDisplay( out );
462  return out;
463 }
464 
465 // //
467 
468