DGtal  1.5.beta
DGtal::detail::SetFunctionsImpl< Container, false, true > Struct Template Reference

#include <DGtal/base/SetFunctions.h>

Static Public Member Functions

static bool isEqual (const Container &S1, const Container &S2)
 
static bool isSubset (const Container &S1, const Container &S2)
 
static Container & assignDifference (Container &S1, const Container &S2)
 
static Container & assignUnion (Container &S1, const Container &S2)
 
static Container & assignIntersection (Container &S1, const Container &S2)
 
static Container & assignSymmetricDifference (Container &S1, const Container &S2)
 

Detailed Description

template<typename Container>
struct DGtal::detail::SetFunctionsImpl< Container, false, true >

Specialization for non-associative, ordered containers. Could be a sorted std::vector or std::list.

Definition at line 646 of file SetFunctions.h.

Member Function Documentation

◆ assignDifference()

template<typename Container >
static Container& DGtal::detail::SetFunctionsImpl< Container, false, true >::assignDifference ( Container &  S1,
const Container &  S2 
)
inlinestatic

Updates the set S1 as S1 - S2. This version uses the fact that the container is ordered.

Parameters
[in,out]S1an input set, S1 - S2 as output.
[in]S2another input set.

Definition at line 691 of file SetFunctions.h.

692  {
693  typedef ComparatorAdapter< Container, false, true, false >
694  CompAdapter;
695 
696  Container S;
697  std::swap( S, S1 );
698  std::set_difference( S.begin(), S.end(), S2.begin(), S2.end(),
699  std::inserter( S1, S1.end() ),
700  CompAdapter::less( S1 ) );
701  return S1;
702  }

◆ assignIntersection()

template<typename Container >
static Container& DGtal::detail::SetFunctionsImpl< Container, false, true >::assignIntersection ( Container &  S1,
const Container &  S2 
)
inlinestatic

Updates the set S1 as \( S1 \cap S2 \). This version uses the fact that the container is ordered.

Parameters
[in,out]S1an input set, \( S1 \cap S2 \) as output.
[in]S2another input set.

Definition at line 729 of file SetFunctions.h.

730  {
731  typedef ComparatorAdapter< Container, false, true, false >
732  CompAdapter;
733 
734  Container S;
735  std::swap( S, S1 );
736  std::set_intersection( S.begin(), S.end(), S2.begin(), S2.end(),
737  std::inserter( S1, S1.end() ),
738  CompAdapter::less( S1 ) );
739  return S1;
740  }

◆ assignSymmetricDifference()

template<typename Container >
static Container& DGtal::detail::SetFunctionsImpl< Container, false, true >::assignSymmetricDifference ( Container &  S1,
const Container &  S2 
)
inlinestatic

Updates the set S1 as \( S1 \Delta S2 \). This version uses the fact that the container is ordered.

Parameters
[in,out]S1an input set, \( S1 \Delta S2 \) as output.
[in]S2another input set.

Definition at line 748 of file SetFunctions.h.

749  {
750  typedef ComparatorAdapter< Container, false, true, false >
751  CompAdapter;
752 
753  Container S;
754  std::swap( S, S1 );
755  std::set_symmetric_difference( S.begin(), S.end(), S2.begin(), S2.end(),
756  std::inserter( S1, S1.end() ),
757  CompAdapter::less( S1 ) );
758  return S1;
759  }

◆ assignUnion()

template<typename Container >
static Container& DGtal::detail::SetFunctionsImpl< Container, false, true >::assignUnion ( Container &  S1,
const Container &  S2 
)
inlinestatic

Updates the set S1 as \( S1 \cup S2 \). This version uses the fact that the container is ordered.

Parameters
[in,out]S1an input set, \( S1 \cup S2 \) as output.
[in]S2another input set.

Definition at line 710 of file SetFunctions.h.

711  {
712  typedef ComparatorAdapter< Container, false, true, false >
713  CompAdapter;
714 
715  Container S;
716  std::swap( S, S1 );
717  std::set_union( S.begin(), S.end(), S2.begin(), S2.end(),
718  std::inserter( S1, S1.end() ),
719  CompAdapter::less( S1 ) );
720  return S1;
721  }

◆ isEqual()

template<typename Container >
static bool DGtal::detail::SetFunctionsImpl< Container, false, true >::isEqual ( const Container &  S1,
const Container &  S2 
)
inlinestatic

Equality test. This version uses the fact that the container is ordered.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is equal to S2 (seen as sets).

Definition at line 655 of file SetFunctions.h.

656  {
657  typedef ComparatorAdapter< Container, false, true, false >
658  CompAdapter;
659 
660  // Checks size first.
661  if ( S1.size() != S2.size() ) return false;
662  return std::equal( S1.begin(), S1.end(), S2.begin(),
663  CompAdapter::equal_to( S1 ) );
664  }

◆ isSubset()

template<typename Container >
static bool DGtal::detail::SetFunctionsImpl< Container, false, true >::isSubset ( const Container &  S1,
const Container &  S2 
)
inlinestatic

Inclusion test. This version uses the fact that the container is ordered.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is a subset of S2.

Definition at line 674 of file SetFunctions.h.

675  {
676  typedef ComparatorAdapter< Container, false, true, false >
677  CompAdapter;
678 
679  // Checks size first.
680  if ( S1.size() > S2.size() ) return false;
681  return std::includes( S2.begin(), S2.end(), S1.begin(), S1.end(),
682  CompAdapter::less( S1 ) );
683  }

The documentation for this struct was generated from the following file: