DGtal 1.3.0
Loading...
Searching...
No Matches
Static Public Member Functions
DGtal::detail::SetFunctionsImpl< Container, true, 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, true, true >

Specialization for associative, ordered containers.

Definition at line 514 of file SetFunctions.h.

Member Function Documentation

◆ assignDifference()

template<typename Container >
static Container & DGtal::detail::SetFunctionsImpl< Container, true, 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 566 of file SetFunctions.h.

567 {
568 typedef ComparatorAdapter< Container, true, true,
569 IsPairAssociativeContainer< Container >::value >
570 CompAdapter;
571
572 Container S;
573 std::swap( S, S1 );
574 std::set_difference( S.begin(), S.end(), S2.begin(), S2.end(),
575 std::inserter( S1, S1.end() ),
576 CompAdapter::less( S1 ) );
577 return S1;
578 }

◆ assignIntersection()

template<typename Container >
static Container & DGtal::detail::SetFunctionsImpl< Container, true, 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 606 of file SetFunctions.h.

607 {
608 typedef ComparatorAdapter< Container, true, true,
609 IsPairAssociativeContainer< Container >::value >
610 CompAdapter;
611
612 Container S;
613 std::swap( S, S1 );
614 std::set_intersection( S.begin(), S.end(), S2.begin(), S2.end(),
615 std::inserter( S1, S1.end() ),
616 CompAdapter::less( S1 ) );
617 return S1;
618 }

◆ assignSymmetricDifference()

template<typename Container >
static Container & DGtal::detail::SetFunctionsImpl< Container, true, 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 626 of file SetFunctions.h.

627 {
628 typedef ComparatorAdapter< Container, true, true,
629 IsPairAssociativeContainer< Container >::value >
630 CompAdapter;
631
632 Container S;
633 std::swap( S, S1 );
634 std::set_symmetric_difference( S.begin(), S.end(), S2.begin(), S2.end(),
635 std::inserter( S1, S1.end() ),
636 CompAdapter::less( S1 ) );
637 return S1;
638 }

◆ assignUnion()

template<typename Container >
static Container & DGtal::detail::SetFunctionsImpl< Container, true, 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 586 of file SetFunctions.h.

587 {
588 typedef ComparatorAdapter< Container, true, true,
589 IsPairAssociativeContainer< Container >::value >
590 CompAdapter;
591
592 Container S;
593 std::swap( S, S1 );
594 std::set_union( S.begin(), S.end(), S2.begin(), S2.end(),
595 std::inserter( S1, S1.end() ),
596 CompAdapter::less( S1 ) );
597 return S1;
598 }

◆ isEqual()

template<typename Container >
static bool DGtal::detail::SetFunctionsImpl< Container, true, 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 524 of file SetFunctions.h.

525 {
526 // Checks size first.
527 if ( S1.size() != S2.size() ) return false;
528 // One has to be careful for comparing keys in set-like
529 // structure, we only have an operator<. Hence a == b is defined as
530 // ( ! a<b ) && ( ! b<a ).
531 typedef ComparatorAdapter< Container, true, true,
532 IsPairAssociativeContainer< Container >::value >
533 CompAdapter;
534
535 return std::equal( S1.begin(), S1.end(), S2.begin(),
536 CompAdapter::equal_to( S1 ) );
537 }

◆ isSubset()

template<typename Container >
static bool DGtal::detail::SetFunctionsImpl< Container, true, 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 547 of file SetFunctions.h.

548 {
549 // Checks size first.
550 if ( S1.size() > S2.size() ) return false;
551 typedef ComparatorAdapter< Container, true, true,
552 IsPairAssociativeContainer< Container >::value >
553 CompAdapter;
554
555 return std::includes( S2.begin(), S2.end(),
556 S1.begin(), S1.end(), CompAdapter::less( S1 ) );
557 }

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