text:
#ifndef __TBB_test_common_concepts_common_H
#define __TBB_test_common_concepts_common_H
#include "tbb/parallel_pipeline.h"
#include "tbb/parallel_for_each.h"
#include "tbb/flow_graph.h"
#include "tbb/parallel_scan.h"
#include "iterator.h"
#include <vector>

#if __TBB_CPP20_CONCEPTS_PRESENT

namespace test_concepts {

struct Dummy {};

enum class State {
    correct,
    incorrect_first_input,
    incorrect_second_input,
    incorrect_third_input,
    incorrect_return_type,
    incorrect_constness,
    not_defined,
    incorrect,
    non_constant_expression
};

struct Copyable { Copyable( const Copyable& ) = default; };
struct NonCopyable { NonCopyable( const NonCopyable& ) = delete; };
struct CopyAssignable { CopyAssignable& operator=( const CopyAssignable& ) = default; };
struct NonCopyAssignable { NonCopyAssignable& operator=( const NonCopyAssignable& ) = delete; };

struct DefaultInitializable { DefaultInitializable() = default; };
struct NonDefaultInitializable { NonDefaultInitializable() = delete; };

namespace blocked_range_value {

template <bool EnableCopyCtor, bool EnableCopyAssignment, bool EnableDtor,
          State EnableOperatorLess, State EnableOperatorMinus, State EnableOperatorPlusSizeT>
struct BlockedRangeValue {
    BlockedRangeValue( const BlockedRangeValue& ) requires EnableCopyCtor = default;

    BlockedRangeValue& operator=( const BlockedRangeValue& ) requires EnableCopyAssignment = default;

    // Prospective destructors
    ~BlockedRangeValue() requires EnableDtor = default;
    ~BlockedRangeValue() = delete;

    bool operator<( const BlockedRangeValue& ) const requires (EnableOperatorLess == State::correct) { return true; }
    bool operator<( Dummy ) const requires (EnableOperatorLess == State::incorrect_first_input) { return true; }
    Dummy operator<( const BlockedRangeValue& ) const requires (EnableOperatorLess == State::incorrect_return_type) { return Dummy{}; }
    bool operator<( const BlockedRangeValue& ) requires (EnableOperatorLess == State::incorrect_constness) { return true; }

    std::size_t operator-( const BlockedRangeValue& ) const requires (EnableOperatorMinus == State::correct) { return 0; }
    std::size_t operator-( Dummy ) const requires (EnableOperatorMinus == State::incorrect_first_input) { return 0; }
    Dummy operator-( const BlockedRangeValue& ) const requires (EnableOperatorMinus == State::incorrect_return_type) { return Dummy{}; }
    std::size_t operator-( const BlockedRangeValue& ) requires (EnableOperatorMinus == State::incorrect_constness) { return 0; }

    BlockedRangeValue operator+( std::size_t ) const requires (EnableOperatorPlusSizeT == State::correct) { return *this; }
    BlockedRangeValue operator+( Dummy ) const requires (EnableOperatorPlusSizeT == State::incorrect_first_input) { return *this; }
    Dummy operator+( std::size_t ) const requires (EnableOperatorPlusSizeT == State::incorrect_return_type) { return Dummy{}; }
    BlockedRangeValue operator+( std::size_t ) requires (EnableOperatorPlusSizeT == State::incorrect_constness) { return *this; }
};

using Correct = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using NonCopyable = BlockedRangeValue</*CopyCtor = */false, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using NonCopyAssignable = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */false, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using NonDestructible = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */false, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using NoOperatorLess = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::not_defined, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using OperatorLessNonConst = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::incorrect_constness, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using WrongInputOperatorLess = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::incorrect_first_input, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using WrongReturnOperatorLess = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::incorrect_return_type, /*Minus = */State::correct, /*PlusSizeT = */State::correct>;
using NoOperatorMinus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::not_defined, /*PlusSizeT = */State::correct>;
using OperatorMinusNonConst = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_constness, /*PlusSizeT = */State::correct>;
using WrongInputOperatorMinus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_first_input, /*PlusSizeT = */State::correct>;
using WrongReturnOperatorMinus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_return_type, /*PlusSizeT = */State::correct>;
using NoOperatorPlus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::not_defined>;
using OperatorPlusNonConst = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::incorrect_constness>;
using WrongInputOperatorPlus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::incorrect_first_input>;
using WrongReturnOperatorPlus = BlockedRangeValue</*CopyCtor = */true, /*CopyAssignment = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*PlusSizeT = */State::incorrect_return_type>;

} // namespace blocked_range_value
namespace range {

template <bool EnableCopyCtor, bool EnableSplitCtor, bool EnableDtor, State EnableEmpty, State EnableIsDivisible>
struct Range {
    Range( Range&, tbb::split ) requires EnableSplitCtor {}
    Range( const Range& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~Range() requires EnableDtor = default;
    ~Range() = delete;

    bool empty() const requires (EnableEmpty == State::correct) { return true; }
    bool empty() requires (EnableEmpty == State::incorrect_constness) { return true; }
    Dummy empty() const requires (EnableEmpty == State::incorrect_return_type) { return Dummy{}; }

    bool is_divisible() const requires (EnableIsDivisible == State::correct) { return true; }
    bool is_divisible() requires (EnableIsDivisible == State::incorrect_constness) { return true; }
    Dummy is_divisible() const requires (EnableIsDivisible == State::incorrect_return_type) { return Dummy{}; }
};

using Correct = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::correct>;
using NonCopyable = Range</*CopyCtor = */false, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::correct>;
using NonSplittable = Range</*CopyCtor = */true, /*SplitCtor = */false, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::correct>;
using NonDestructible = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */false, /*Empty = */State::correct, /*IsDivisible = */State::correct>;
using NoEmpty = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::not_defined, /*IsDivisible = */State::correct>;
using EmptyNonConst = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::incorrect_constness, /*IsDivisible = */State::correct>;
using WrongReturnEmpty = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::incorrect_return_type, /*IsDivisible = */State::correct>;
using NoIsDivisible = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::not_defined>;
using IsDivisibleNonConst = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::incorrect_constness>;
using WrongReturnIsDivisible = Range</*CopyCtor = */true, /*SplitCtor = */true, /*Dtor = */true, /*Empty = */State::correct, /*IsDivisible = */State::incorrect_return_type>;

} // namespace range
namespace parallel_for_body {

template <typename Range, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct ParallelForBody {
    ParallelForBody( const ParallelForBody& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~ParallelForBody() requires EnableDtor = default;
    ~ParallelForBody() = delete;

    void operator()( Range& ) const requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( Range& ) requires (EnableFunctionCallOperator == State::incorrect_constness) {}
    void operator()( Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) {}
};

template <typename R> using Correct = ParallelForBody<R, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename R> using NonCopyable = ParallelForBody<R, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename R> using NonDestructible = ParallelForBody<R, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename R> using NoOperatorRoundBrackets = ParallelForBody<R, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename R> using OperatorRoundBracketsNonConst = ParallelForBody<R, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_constness>;
template <typename R> using WrongInputOperatorRoundBrackets = ParallelForBody<R, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
} // namespace parallel_for_body
namespace parallel_for_function {

template <typename Index, State EnableFunctionCallOperator>
struct ParallelForFunc {
    void operator()( Index ) const requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( Index ) requires (EnableFunctionCallOperator == State::incorrect_constness) {}
    void operator()( Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) {}
};

template <typename I> using Correct = ParallelForFunc<I, /*() = */State::correct>;
template <typename I> using NoOperatorRoundBrackets = ParallelForFunc<I, /*() = */State::not_defined>;
template <typename I> using OperatorRoundBracketsNonConst = ParallelForFunc<I, /*() = */State::incorrect_constness>;
template <typename I> using WrongInputOperatorRoundBrackets = ParallelForFunc<I, /*() = */State::incorrect_first_input>;
} // namespace parallel_for_function
namespace parallel_for_index {
template <bool EnableIntCtor, bool EnableCopyCtor, bool EnableCopyAssign, bool EnableDtor,
          State EnableLess, State EnableMinus, State EnablePlus>
struct ParallelForIndex {
    ParallelForIndex(int) requires EnableIntCtor {}
    ParallelForIndex( const ParallelForIndex& ) requires EnableCopyCtor = default;
    ParallelForIndex& operator=( const ParallelForIndex& ) requires EnableCopyAssign = default;
    // Prospective destructors
    ~ParallelForIndex() requires EnableDtor = default;
    ~ParallelForIndex() = delete;

    bool operator<( const ParallelForIndex& ) const requires (EnableLess == State::correct) { return true; }
    bool operator<( const ParallelForIndex& ) requires (EnableLess == State::incorrect_constness) { return true; }
    bool operator<( Dummy ) const requires (EnableLess == State::incorrect_first_input) { return true; }
    Dummy operator<( const ParallelForIndex& ) const requires (EnableLess == State::incorrect_return_type) { return Dummy{}; }

    std::size_t operator-( const ParallelForIndex& ) const requires (EnableMinus == State::correct) { return 0; }
    std::size_t operator-( const ParallelForIndex& ) requires (EnableMinus == State::incorrect_constness) { return 0; }
    std::size_t operator-( Dummy ) const requires (EnableMinus == State::incorrect_first_input) { return 0; }
    Dummy operator-( const ParallelForIndex& ) const requires (EnableMinus == State::incorrect_return_type) { return Dummy{}; }

    ParallelForIndex operator+( std::size_t ) const requires (EnablePlus == State::correct) { return *this; }
    ParallelForIndex operator+( std::size_t ) requires (EnablePlus == State::incorrect_constness) { return *this; }
    ParallelForIndex operator+( Dummy ) const requires (EnablePlus == State::incorrect_first_input) { return *this; }
    Dummy operator+( std::size_t ) const requires (EnablePlus == State::incorrect_return_type) { return Dummy{}; }
};

using Correct = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::correct>;
using NoIntCtor = ParallelForIndex</*IntCtor = */false, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::correct>;
using NonCopyable = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */false, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::correct>;
using NonCopyAssignable = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */false, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::correct>;
using NonDestructible = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */false, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::correct>;
using NoOperatorLess = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::not_defined, /*Minus = */State::correct, /*Plus = */State::correct>;
using OperatorLessNonConst = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::incorrect_constness, /*Minus = */State::correct, /*Plus = */State::correct>;
using WrongInputOperatorLess = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::incorrect_first_input, /*Minus = */State::correct, /*Plus = */State::correct>;
using WrongReturnOperatorLess = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::incorrect_return_type, /*Minus = */State::correct, /*Plus = */State::correct>;
using NoOperatorMinus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::not_defined, /*Plus = */State::correct>;
using OperatorMinusNonConst = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_constness, /*Plus = */State::correct>;
using WrongInputOperatorMinus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_first_input, /*Plus = */State::correct>;
using WrongReturnOperatorMinus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::incorrect_return_type, /*Plus = */State::correct>;
using NoOperatorPlus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::not_defined>;
using OperatorPlusNonConst = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::incorrect_constness>;
using WrongInputOperatorPlus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::incorrect_first_input>;
using WrongReturnOperatorPlus = ParallelForIndex</*IntCtor = */true, /*CopyCtor = */true, /*CopyAssign = */true, /*Dtor = */true, /*Less = */State::correct, /*Minus = */State::correct, /*Plus = */State::incorrect_return_type>;
} // namespace parallel_for_index
namespace parallel_for_each_body {

template <typename T, State EnableFunctionCallOperator>
struct ParallelForEachBody {
    void operator()( const T& ) const requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( const T& ) requires (EnableFunctionCallOperator == State::incorrect_constness) {}
    void operator()( Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) {}
};

template <typename T, typename FeederT, State EnableFunctionCallOperator>
struct ParallelForEachFeederBody {
    void operator()( const T&, tbb::feeder<FeederT>& ) const requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( const T&, tbb::feeder<FeederT>& ) requires (EnableFunctionCallOperator == State::incorrect_constness) {}
    void operator()( Dummy, tbb::feeder<FeederT>& ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) {}
    void operator()( const T&, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) {}
};

template <typename T> using Correct = ParallelForEachBody<T, /*() = */State::correct>;
template <typename T> using NoOperatorRoundBrackets = ParallelForEachBody<T, /*() = */State::not_defined>;
template <typename T> using OperatorRoundBracketsNonConst = ParallelForEachBody<T, /*() = */State::incorrect_constness>;
template <typename T> using WrongInputOperatorRoundBrackets = ParallelForEachBody<T, /*() = */State::incorrect_first_input>;

template <typename T, typename F = T> using WithFeeder = ParallelForEachFeederBody<T, F, /*() = */State::correct>;
template <typename T, typename F = T> using WithFeederNoOperatorRoundBrackets = ParallelForEachFeederBody<T, F, /*() = */State::not_defined>;
template <typename T, typename F = T> using WithFeederOperatorRoundBracketsNonConst = ParallelForEachFeederBody<T, F, /*() = */State::incorrect_constness>;
template <typename T, typename F = T> using WithFeederWrongFirstInputOperatorRoundBrackets = ParallelForEachFeederBody<T, F, /*() = */State::incorrect_first_input>;
template <typename T, typename F = T> using WithFeederWrongSecondInputOperatorRoundBrackets = ParallelForEachFeederBody<T, F, /*() = */State::incorrect_second_input>;
} // namespace parallel_for_each_body
namespace parallel_sort_value {
template<bool MovableV, bool MoveAssignableV, bool ComparableV>
struct ParallelSortValue
{
    ParallelSortValue(ParallelSortValue&&) requires MovableV = default;
    ParallelSortValue& operator=(ParallelSortValue&&) requires MoveAssignableV = default;

    friend bool operator<(const ParallelSortValue&, const ParallelSortValue&) requires ComparableV { return true; }
};

using CorrectValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */true, /*ComparableV = */true>;
using NonMovableValue = ParallelSortValue</*MovableV = */false, /*MoveAssignableV = */true, /*ComparableV = */true>;
using NonMoveAssignableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */false, /*ComparableV = */true>;
using NonComparableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */true, /*ComparableV = */false>;
} // namespace parallel_sort_value
template <typename T>
class ConstantIT {
    T data{};
    const T& operator* () const { return data; }
};
namespace container_based_sequence {

template <bool EnableBegin, bool EnableEnd, typename T = int>
struct ContainerBasedSequence {
    using iterator = T*;
    T* begin() requires EnableBegin { return nullptr; }
    T* end() requires EnableEnd { return nullptr; }
};

using Correct = ContainerBasedSequence</*Begin = */true, /*End = */true>;
using NoBegin = ContainerBasedSequence</*Begin = */false, /*End = */true>;
using NoEnd = ContainerBasedSequence</*Begin = */true, /*End = */false>;

template <typename T>
using CustomValueCBS = ContainerBasedSequence</*Begin = */true, /*End = */true, T>;

struct ConstantCBS {
    ConstantIT<int> begin() const { return ConstantIT<int>{}; }
    ConstantIT<int> end() const { return ConstantIT<int>{}; }
};

struct ForwardIteratorCBS {
    utils::ForwardIterator<int> begin() { return utils::ForwardIterator<int>{}; }
    utils::ForwardIterator<int> end() { return begin(); }
};

} // namespace container_based_sequence
namespace parallel_reduce_body {

template <typename Range, bool EnableSplitCtor, bool EnableDtor, State EnableFunctionCallOperator, State EnableJoin>
struct ParallelReduceBody {
    ParallelReduceBody( ParallelReduceBody&, tbb::split ) requires EnableSplitCtor {}
    // Prospective destructors
    ~ParallelReduceBody() requires EnableDtor = default;
    ~ParallelReduceBody() = delete;

    void operator()( const Range& ) requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) {}

    void join( ParallelReduceBody& ) requires (EnableJoin == State::correct) {}
    void join( Dummy ) requires (EnableJoin == State::incorrect_first_input) {}
};

template <typename R> using Correct = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */true, /*() = */State::correct, /*Join = */State::correct>;
template <typename R> using NonSplittable = ParallelReduceBody<R, /*SplitCtor = */false, /*Dtor = */true, /*() = */State::correct, /*Join = */State::correct>;
template <typename R> using NonDestructible = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */false, /*() = */State::correct, /*Join = */State::correct>;
template <typename R> using NoOperatorRoundBrackets = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */true, /*() = */State::not_defined, /*Join = */State::correct>;
template <typename R> using WrongInputOperatorRoundBrackets = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input, /*Join = */State::correct>;
template <typename R> using NoJoin = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */true, /*() = */State::correct, /*Join = */State::not_defined>;
template <typename R> using WrongInputJoin = ParallelReduceBody<R, /*SplitCtor = */true, /*Dtor = */true, /*() = */State::correct, /*Join = */State::incorrect_first_input>;
} // namespace parallel_reduce_body
namespace parallel_reduce_function {

template <typename Range, State EnableFunctionCallOperator>
struct ParallelReduceFunction {
    int operator()( const Range&, const int& ) const requires (EnableFunctionCallOperator == State::correct) { return 0; }
    int operator()( const Range&, const int& ) requires (EnableFunctionCallOperator == State::incorrect_constness) { return 0; }
    int operator()( Dummy, const int& ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) { return 0; }
    int operator()( const Range&, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) { return 0; }
    Dummy operator()( const Range&, const int& ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename R> using Correct = ParallelReduceFunction<R, /*() = */State::correct>;
template <typename R> using NoOperatorRoundBrackets = ParallelReduceFunction<R, /*() = */State::not_defined>;
template <typename R> using OperatorRoundBracketsNonConst = ParallelReduceFunction<R, /*() = */State::incorrect_constness>;
template <typename R> using WrongFirstInputOperatorRoundBrackets = ParallelReduceFunction<R, /*() = */State::incorrect_first_input>;
template <typename R> using WrongSecondInputOperatorRoundBrackets = ParallelReduceFunction<R, /*() = */State::incorrect_second_input>;
template <typename R> using WrongReturnOperatorRoundBrackets = ParallelReduceFunction<R, /*() = */State::incorrect_return_type>;
} // namespace parallel_reduce_function
namespace parallel_reduce_combine {

template <typename T, State EnableFunctionCallOperator>
struct ParallelReduceCombine {
    T operator()( const T& a, const T& ) const requires (EnableFunctionCallOperator == State::correct) { return a; }
    T operator()( const T& a, const T& ) requires (EnableFunctionCallOperator == State::incorrect_constness) { return a; }
    T operator()( Dummy, const T& a ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) { return a; }
    T operator()( const T& a, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) { return a; }
    Dummy operator()( const T&, const T& ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename T> using Correct = ParallelReduceCombine<T, /*() = */State::correct>;
template <typename T> using NoOperatorRoundBrackets = ParallelReduceCombine<T, /*() = */State::not_defined>;
template <typename T> using OperatorRoundBracketsNonConst = ParallelReduceCombine<T, /*() = */State::incorrect_constness>;
template <typename T> using WrongFirstInputOperatorRoundBrackets = ParallelReduceCombine<T, /*() = */State::incorrect_first_input>;
template <typename T> using WrongSecondInputOperatorRoundBrackets = ParallelReduceCombine<T, /*() = */State::incorrect_second_input>;
template <typename T> using WrongReturnOperatorRoundBrackets = ParallelReduceCombine<T, /*() = */State::incorrect_return_type>;
} // namespace parallel_reduce_reduction
namespace parallel_scan_body {

template <typename Range, bool EnableSplitCtor, State EnableReverseJoin, State EnableAssign, State EnablePreScanRoundBrackets, State EnableFinalScanRoundBrackets>
struct ParallelScanBody {
    ParallelScanBody( ParallelScanBody&, tbb::split ) requires EnableSplitCtor {}

    void reverse_join( ParallelScanBody& ) requires (EnableReverseJoin == State::correct) {}
    void reverse_join( Dummy ) requires (EnableReverseJoin == State::incorrect_first_input) {}

    void assign( ParallelScanBody& ) requires (EnableAssign == State::correct) {}
    void assign( Dummy ) requires (EnableAssign == State::incorrect_first_input) {}

    void operator()( const Range&, tbb::pre_scan_tag ) requires (EnablePreScanRoundBrackets == State::correct) {}
    void operator()( Dummy, tbb::pre_scan_tag ) requires (EnablePreScanRoundBrackets == State::incorrect_first_input) {}
    void operator()( const Range&, Dummy ) requires (EnablePreScanRoundBrackets == State::incorrect_second_input) {}

    void operator()( const Range&, tbb::final_scan_tag ) requires (EnableFinalScanRoundBrackets == State::correct) {}
    void operator()( Dummy, tbb::final_scan_tag ) requires (EnableFinalScanRoundBrackets == State::incorrect_first_input) {}
    void operator()( const Range&, Dummy ) requires (EnableFinalScanRoundBrackets == State::incorrect_second_input) {}
};

template <typename R> using Correct = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using NonSplittable = ParallelScanBody<R, /*SplitCtor = */false, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using NoReverseJoin = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::not_defined, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using WrongInputReverseJoin = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::incorrect_first_input, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using NoAssign = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::not_defined, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using WrongInputAssign = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::incorrect_first_input, /*PreScan = */State::correct, /*FinalScan = */State::correct>;
template <typename R> using NoPreScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::not_defined, /*FinalScan = */State::correct>;
template <typename R> using WrongFirstInputPreScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::incorrect_first_input, /*FinalScan = */State::correct>;
template <typename R> using WrongSecondInputPreScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::incorrect_second_input, /*FinalScan = */State::correct>;
template <typename R> using NoFinalScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::not_defined>;
template <typename R> using WrongFirstInputFinalScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::incorrect_first_input>;
template <typename R> using WrongSecondInputFinalScanOperatorRoundBrackets = ParallelScanBody<R, /*SplitCtor = */true, /*ReverseJoin = */State::correct, /*Assign = */State::correct, /*PreScan = */State::correct, /*FinalScan = */State::incorrect_second_input>;
} // namespace parallel_scan_body
namespace parallel_scan_function {

template <typename Range, typename T, State EnableFunctionCallOperator>
struct ParallelScanFunction {
    T operator()( const Range&, const T& a, bool ) const requires (EnableFunctionCallOperator == State::correct) { return a; }
    T operator()( const Range&, const T& a, bool ) requires (EnableFunctionCallOperator == State::incorrect_constness) { return a; }
    T operator()( Dummy, const T& a, bool ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) { return a; }
    T operator()( const Range&, Dummy, bool ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) { return T{}; }
    T operator()( const Range&, const T& a, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_third_input) { return a; }
    Dummy operator()( const Range&, const T& a, bool ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename R, typename T> using Correct = ParallelScanFunction<R, T, /*() = */State::correct>;
template <typename R, typename T> using NoOperatorRoundBrackets = ParallelScanFunction<R, T, /*() = */State::not_defined>;
template <typename R, typename T> using OperatorRoundBracketsNonConst = ParallelScanFunction<R, T, /*() = */State::incorrect_constness>;
template <typename R, typename T> using WrongFirstInputOperatorRoundBrackets = ParallelScanFunction<R, T, /*() = */State::incorrect_first_input>;
template <typename R, typename T> using WrongSecondInputOperatorRoundBrackets = ParallelScanFunction<R, T, /*() = */State::incorrect_second_input>;
template <typename R, typename T> using WrongThirdInputOperatorRoundBrackets = ParallelScanFunction<R, T, /*() = */State::incorrect_third_input>;
template <typename R, typename T> using WrongReturnOperatorRoundBrackets = ParallelScanFunction<R, T, /*() = */State::incorrect_return_type>;
} // namespace parallel_scan_function
namespace parallel_scan_combine {
using namespace parallel_reduce_combine;
} // namespace parallel_scan_combine
namespace compare {

template <typename T, State EnableFunctionCallOperator>
struct Compare {
    bool operator()( const T&, const T& ) const requires (EnableFunctionCallOperator == State::correct) { return true; }
    bool operator()( Dummy, const T& ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) { return true; }
    bool operator()( const T&, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) { return true; }
    Dummy operator()( const T&, const T& ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename T> using Correct = Compare<T, /*() = */State::correct>;
template <typename T> using NoOperatorRoundBrackets = Compare<T, /*() = */State::not_defined>;
template <typename T> using WrongFirstInputOperatorRoundBrackets = Compare<T, /*() = */State::incorrect_first_input>;
template <typename T> using WrongSecondInputOperatorRoundBrackets = Compare<T, /*() = */State::incorrect_second_input>;
template <typename T> using WrongReturnOperatorRoundBrackets = Compare<T, /*() = */State::incorrect_return_type>;
} // namespace compare

namespace hash_compare {

template <typename Key, bool EnableCopyCtor, bool EnableDtor, State EnableHash, State EnableEqual>
struct HashCompare {
    HashCompare( const HashCompare& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~HashCompare() requires EnableDtor = default;
    ~HashCompare() = delete;

    std::size_t hash( const Key& ) const requires (EnableHash == State::correct) { return 0; }
    std::size_t hash( const Key& ) requires (EnableHash == State::incorrect_constness) { return 0; }
    std::size_t hash( Dummy ) const requires (EnableHash == State::incorrect_first_input) { return 0; }
    Dummy hash( const Key& ) const requires (EnableHash == State::incorrect_return_type) { return Dummy{}; }

    bool equal( const Key&, const Key& ) const requires (EnableEqual == State::correct) { return true; }
    bool equal( const Key&, const Key& ) requires (EnableEqual == State::incorrect_constness) { return true; }
    bool equal( Dummy, const Key& ) const requires (EnableEqual == State::incorrect_first_input) { return true; }
    bool equal( const Key&, Dummy ) const requires (EnableEqual == State::incorrect_second_input) { return true; }
    Dummy equal( const Key&, const Key& ) const requires (EnableEqual == State::incorrect_return_type) { return Dummy{}; }
};

template <typename K> using Correct = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::correct>;
template <typename K> using NonCopyable = HashCompare<K, /*CopyCtor = */false, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::correct>;
template <typename K> using NonDestructible = HashCompare<K, /*CopyCtor = */true, /*Dtor = */false, /*Hash = */State::correct, /*Equal = */State::correct>;
template <typename K> using NoHash = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::not_defined, /*Equal = */State::correct>;
template <typename K> using HashNonConst = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::incorrect_constness, /*Equal = */State::correct>;
template <typename K> using WrongInputHash = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::incorrect_first_input, /*Equal = */State::correct>;
template <typename K> using WrongReturnHash = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::incorrect_return_type, /*Equal = */State::correct>;
template <typename K> using NoEqual = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::not_defined>;
template <typename K> using EqualNonConst = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::incorrect_constness>;
template <typename K> using WrongFirstInputEqual = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::incorrect_first_input>;
template <typename K> using WrongSecondInputEqual = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::incorrect_second_input>;
template <typename K> using WrongReturnEqual = HashCompare<K, /*CopyCtor = */true, /*Dtor = */true, /*Hash = */State::correct, /*Equal = */State::incorrect_return_type>;

} // namespace hash_compare
namespace rw_mutex {

template <typename RwMutex, bool EnableSLDefaultCtor, bool EnableSLMutexCtor, bool EnableSLDtor, State EnableSLAcquire, State EnableSLTryAcquire, bool EnableSLRelease, State EnableSLUpgrade, State EnableSLDowngrade, State EnableIsWriter>
struct DefineRWScopedLock {
    struct scoped_lock {
        scoped_lock() requires EnableSLDefaultCtor = default;
        scoped_lock( RwMutex&, bool = true ) requires EnableSLMutexCtor {}
        // Prospective destructors
        ~scoped_lock() requires EnableSLDtor = default;
        ~scoped_lock() = delete;

        void acquire( RwMutex&, bool = true ) requires (EnableSLAcquire == State::correct) {}
        void acquire( Dummy, bool = true ) requires (EnableSLAcquire == State::incorrect_first_input) {}
        void acquire( RwMutex&, Dummy = Dummy{} ) requires (EnableSLAcquire == State::incorrect_second_input) {}

        bool try_acquire( RwMutex&, bool = true ) requires (EnableSLTryAcquire == State::correct) { return true; }
        bool try_acquire( Dummy, bool = true ) requires (EnableSLTryAcquire == State::incorrect_first_input) { return true; }
        bool try_acquire( RwMutex&, Dummy = Dummy{} ) requires (EnableSLTryAcquire == State::incorrect_second_input) { return true; }
        Dummy try_acquire( RwMutex&, bool = true ) requires (EnableSLTryAcquire == State::incorrect_return_type) { return Dummy{}; }

        void release() requires (EnableSLRelease) {}

        bool upgrade_to_writer() requires (EnableSLUpgrade == State::correct) { return true; }
        Dummy upgrade_to_writer() requires (EnableSLUpgrade == State::incorrect_return_type) { return Dummy{}; }

        bool downgrade_to_reader() requires (EnableSLDowngrade == State::correct) { return true; }
        Dummy downgrade_to_reader() requires (EnableSLDowngrade == State::incorrect_return_type) { return Dummy{}; }

        bool is_writer() const requires (EnableIsWriter == State::correct) { return true; }
        Dummy is_writer() const requires (EnableIsWriter == State::incorrect_return_type) { return Dummy{}; }
        bool is_writer() requires (EnableIsWriter == State::incorrect_constness) { return true; }
    };
};

template <State S>
inline const bool mutex_trait_impl = true;

template <>
inline const int mutex_trait_impl<State::incorrect> = 0;

template <>
inline bool mutex_trait_impl<State::non_constant_expression> = true;

template <bool EnableScopedLock, bool EnableSLDefaultCtor, bool EnableSLMutexCtor, bool EnableSLDtor, State EnableSLAcquire, State EnableSLTryAcquire,
          bool EnableSLRelease, State EnableSLUpgrade, State EnableSLDowngrade, State EnableSLIsWriter>
struct RWMutex
    : std::conditional_t<EnableScopedLock, DefineRWScopedLock<RWMutex<EnableScopedLock, EnableSLDefaultCtor, EnableSLMutexCtor, EnableSLDtor, EnableSLAcquire, EnableSLTryAcquire, EnableSLRelease, EnableSLUpgrade, EnableSLDowngrade, EnableSLIsWriter>,
                                                                      EnableSLDefaultCtor, EnableSLMutexCtor, EnableSLDtor, EnableSLAcquire, EnableSLTryAcquire, EnableSLRelease, EnableSLUpgrade, EnableSLDowngrade, EnableSLIsWriter>,
                                           Dummy>
{};

using Correct = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                        /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using NoScopedLock = RWMutex</*ScopedLock = */false, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                             /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoDefaultCtor = RWMutex</*ScopedLock = */true, /*DefaultCtor = */false, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                        /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoMutexCtor = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */false, /*Dtor = */true, /*Acquire = */State::correct,
                                      /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoDtor = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */false, /*Acquire = */State::correct,
                                 /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::not_defined,
                                    /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongFirstInputAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::incorrect_first_input,
                                                 /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongSecondInputAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::incorrect_second_input,
                                                  /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoTryAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                       /*try_acquire = */State::not_defined, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongFirstInputTryAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                                    /*try_acquire = */State::incorrect_first_input, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongSecondInputTryAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                                     /*try_acquire = */State::incorrect_second_input, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongReturnTryAcquire = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                                /*try_acquire = */State::incorrect_return_type, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoRelease = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                    /*try_acquire = */State::correct, /*release = */false, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoUpgrade = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                    /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::not_defined, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockWrongReturnUpgrade = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                             /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::incorrect_return_type, /*downgrade = */State::correct, /*is_writer = */State::correct>;
using ScopedLockNoDowngrade = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                      /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::not_defined, /*is_writer = */State::correct>;
using ScopedLockWrongReturnDowngrade = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                               /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::incorrect_return_type, /*is_writer = */State::correct>;
using ScopedLockNoIsWriter = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                     /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::not_defined>;
using ScopedLockIsWriterNonConst = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                           /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::incorrect_constness>;
using ScopedLockWrongReturnIsWriter = RWMutex</*ScopedLock = */true, /*DefaultCtor = */true, /*MutexCtor = */true, /*Dtor = */true, /*Acquire = */State::correct,
                                              /*try_acquire = */State::correct, /*release = */true, /*upgrade = */State::correct, /*downgrade = */State::correct, /*is_writer = */State::incorrect_return_type>;
} // namespace rw_mutex

// Flow Graph testing infrastructure below
namespace input_node_body {

template <typename Output, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct InputNodeBody {
    InputNodeBody( const InputNodeBody& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~InputNodeBody() requires EnableDtor = default;
    ~InputNodeBody() = delete;

    Output operator()( tbb::flow_control& ) requires (EnableFunctionCallOperator == State::correct) { return Output{}; }
    Output operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) { return Output{}; }
    Dummy operator()( tbb::flow_control& ) requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename O> using Correct = InputNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename O> using NonCopyable = InputNodeBody<O, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename O> using NonDestructible = InputNodeBody<O, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename O> using NoOperatorRoundBrackets = InputNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename O> using WrongInputOperatorRoundBrackets = InputNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename O> using WrongReturnOperatorRoundBrackets = InputNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_return_type>;
} // namespace input_node_body
namespace function_node_body {

template <typename Input, typename Output, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct FunctionNodeBody {
    FunctionNodeBody( const FunctionNodeBody& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~FunctionNodeBody() requires EnableDtor = default;
    ~FunctionNodeBody() = delete;

    Output operator()( const Input& ) requires (EnableFunctionCallOperator == State::correct) { return Output{}; }
    Output operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) { return Dummy{}; }
    Dummy operator()( const Input& ) requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Output{}; }
};

template <typename I, typename O> using Correct = FunctionNodeBody<I, O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonCopyable = FunctionNodeBody<I, O, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonDestructible = FunctionNodeBody<I, O, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename I, typename O> using NoOperatorRoundBrackets = FunctionNodeBody<I, O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename I, typename O> using WrongInputRoundBrackets = FunctionNodeBody<I, O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename I, typename O> using WrongReturnRoundBrackets = FunctionNodeBody<I, O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_return_type>;
} // namespace function_node_body
namespace mf_async_node_body {

template <typename Input, typename Output, typename PortsType, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct PortsNodeBody {
    PortsNodeBody( const PortsNodeBody& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~PortsNodeBody() requires EnableDtor = default;
    ~PortsNodeBody() = delete;

    void operator()( const Input&, PortsType& ) requires (EnableFunctionCallOperator == State::correct) {}
    void operator()( Dummy, PortsType& ) requires (EnableFunctionCallOperator == State::incorrect_first_input) {}
    void operator()( const Input&, Dummy ) requires (EnableFunctionCallOperator == State::incorrect_second_input) {}
};

} // namespace mf_async_node_body
namespace multifunction_node_body {

template <typename Input, typename Output>
using output_ports_type = typename tbb::flow::multifunction_node<Input, Output>::output_ports_type;

using mf_async_node_body::PortsNodeBody;

template <typename I, typename O> using Correct = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonCopyable = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonDestructible = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename I, typename O> using NoOperatorRoundBrackets = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename I, typename O> using WrongFirstInputOperatorRoundBrackets = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename I, typename O> using WrongSecondInputOperatorRoundBrackets = PortsNodeBody<I, O, output_ports_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_second_input>;
} // namespace multifunction_node_body
namespace async_node_body {

template <typename Input, typename Output>
using gateway_type = typename tbb::flow::async_node<Input, Output>::gateway_type;

using mf_async_node_body::PortsNodeBody;

template <typename I, typename O> using Correct = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonCopyable = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename O> using NonDestructible = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename I, typename O> using NoOperatorRoundBrackets = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename I, typename O> using WrongFirstInputOperatorRoundBrackets = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename I, typename O> using WrongSecondInputOperatorRoundBrackets = PortsNodeBody<I, O, gateway_type<I, O>, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_second_input>;
} // namespace async_node_body
namespace continue_node_body {

template <typename Output, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct ContinueNodeBody {
    ContinueNodeBody( const ContinueNodeBody& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~ContinueNodeBody() requires EnableDtor = default;
    ~ContinueNodeBody() = delete;

    Output operator()( tbb::flow::continue_msg ) requires (EnableFunctionCallOperator == State::correct) { return Output{}; }
    Output operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) { return Output{}; }
    Dummy operator()( tbb::flow::continue_msg ) requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename O> using Correct = ContinueNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename O> using NonCopyable = ContinueNodeBody<O, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename O> using NonDestructible = ContinueNodeBody<O, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename O> using NoOperatorRoundBrackets = ContinueNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename O> using WrongInputOperatorRoundBrackets = ContinueNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename O> using WrongReturnOperatorRoundBrackets = ContinueNodeBody<O, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_return_type>;
} // namespace continue_node_body
namespace sequencer {

template <typename T, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct Sequencer {
    Sequencer( const Sequencer& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~Sequencer() requires EnableDtor = default;
    ~Sequencer() = delete;

    std::size_t operator()( const T& ) requires (EnableFunctionCallOperator == State::correct) { return 0; }
    std::size_t operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) { return 0; }
    Dummy operator()( const T& ) requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename T> using Correct = Sequencer<T, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename T> using NonCopyable = Sequencer<T, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename T> using NonDestructible = Sequencer<T, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename T> using NoOperatorRoundBrackets = Sequencer<T, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename T> using WrongInputOperatorRoundBrackets = Sequencer<T, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename T> using WrongReturnOperatorRoundBrackets = Sequencer<T, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_return_type>;
} // namespace sequencer
namespace join_node_function_object {

template <typename Input, typename Key, bool EnableCopyCtor, bool EnableDtor, State EnableFunctionCallOperator>
struct JoinNodeFunctionObject {
    JoinNodeFunctionObject( const JoinNodeFunctionObject& ) requires EnableCopyCtor = default;
    // Prospective destructors
    ~JoinNodeFunctionObject() requires EnableDtor = default;
    ~JoinNodeFunctionObject() = delete;

    Key operator()( const Input& ) requires (EnableFunctionCallOperator == State::correct) { return Key{}; }
    Key operator()( Dummy ) requires (EnableFunctionCallOperator == State::incorrect_first_input) { return Key{}; }
    Dummy operator()( const Input& ) requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename I, typename K> using Correct = JoinNodeFunctionObject<I, K, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename K> using NonCopyable = JoinNodeFunctionObject<I, K, /*CopyCtor = */false, /*Dtor = */true, /*() = */State::correct>;
template <typename I, typename K> using NonDestructible = JoinNodeFunctionObject<I, K, /*CopyCtor = */true, /*Dtor = */false, /*() = */State::correct>;
template <typename I, typename K> using NoOperatorRoundBrackets = JoinNodeFunctionObject<I, K, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::not_defined>;
template <typename I, typename K> using WrongInputOperatorRoundBrackets = JoinNodeFunctionObject<I, K, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_first_input>;
template <typename I, typename K> using WrongReturnOperatorRoundBrackets = JoinNodeFunctionObject<I, K, /*CopyCtor = */true, /*Dtor = */true, /*() = */State::incorrect_return_type>;

} // namespace join_node_function_object

template <typename T>
concept container_range = tbb::detail::tbb_range<T> &&
                          std::input_iterator<typename T::iterator> &&
                          requires(T& range) {
                              typename T::value_type;
                              typename T::reference;
                              typename T::size_type;
                              typename T::difference_type;
                              { range.begin() } -> std::same_as<typename T::iterator>;
                              { range.end() } -> std::same_as<typename T::iterator>;
                              { std::as_const(range).grainsize() } -> std::same_as<typename T::size_type>;
                          };
} // namespace test_concepts

#endif // __TBB_CPP20_CONCEPTS_PRESENT
#endif // __TBB_test_common_concepts_common_H


text:
package org.ihtsdo.otf.ts.helpers;

import java.util.Comparator;
import java.util.List;

/**
 * Container for some kind of results.
 *
 * @param <T> the type for sorting
 */
public interface ResultList<T> {

  /**
   * Returns the number of objects in the list.
   * @return the number of objects in the list
   */
  public int getCount();

  /**
   * Returns the total count.
   *
   * @return the totalCount
   */
  public int getTotalCount();

  /**
   * Sets the total count.
   *
   * @param totalCount the totalCount to set
   */
  public void setTotalCount(int totalCount);

  /**
   * Sorts by the specified comparator.
   *
   * @param comparator the comparator
   */
  public void sortBy(Comparator<T> comparator);

  /**
   * Indicates whether or not the list contains the specified element.
   *
   * @param element the element
   * @return true if so; false otherwise
   */
  public boolean contains(T element);

  /**
   * Adds the object.
   *
   * @param object the object
   */
  public void addObject(T object);

  /**
   * Removes the object.
   *
   * @param object the object
   */
  public void removeObject(T object);

  /**
   * Sets the objects.
   *
   * @param objects the new objects
   */
  public void setObjects(List<T> objects);

  /**
   * Gets the objects.
   *
   * @return the objects
   */
  public List<T> getObjects();
}

redpajama_set_name: RedPajamaGithub


text:
module Ctrl
  class List < Model
    api_accessor :closed, :idBoard, :name, :pos
    api_reader :id

    def initialize(opts)
      super(opts)
      @board = opts["board"] if opts["board"]
      @cards = opts["cards"].map { |card| Card.new(card.merge("list" => self)) } if opts["cards"]
    end

    def self.create(opts); end

    def self.find(s, board)
      s =~CTRL_ID_REGEX ? find_by_id(s) : find_by_name(s, board)
    end

    def self.find_by_id(id)
      List.new(API.get_list(id))
    end

    def self.find_by_name(name, board)
      fuzzy = FuzzyMatch.new(find_all_by_board(board.id), read: :name)
      fuzzy.find(name)
    end

    def self.find_by_position(pos, board)
      pos = 0 if pos == "first" || pos == "top"
      pos = -1 if pos == "last" || pos == "bottom"

      unless pos.is_a? Integer
        fail "Position must by integer, 'top', 'first', 'bottom', or 'last'"
      end

      find_all_by_board(board.id).sort_by(&:position)[pos]
    end

    def self.find_all_by_board(board_id)
      API.get_lists_for_board(board_id).map{ |list| List.new(list) }
    end

    def board
      @board ||= Board.find_by_id(@idBoard)
    end

    def cards
      return @cards if @cards
      if @board && @board.instance_variable_defined?("@cards")
        @board.cards.select { |c| c.idList == id }
      else
        @cards = API.get_cards_for_list(id).map { |card| Card.new(card.merge("list" => self)) }
      end
    end

    def print(opts = {})
      if opts[:labels] && opts[:labels].any?
        valid_labels = opts[:labels]
      else
        valid_labels = board.cards.map(&:label_names).flatten.uniq
      end

      selected_cards = cards.select { |c| (valid_labels & c.label_names).any? }
      unless selected_cards.empty? && opts[:hide_empty]
        title = "☰ #{name.truncate(80)}".wrap({indent: opts[:indent]}).bright
        puts "\n#{title}"
        selected_cards.each { |c| c.print(opts.merge({indent: (opts[:indent] || 0) + 2})) }
      end
    end

    # TODO
    #def count; end
  end
end


text:
package fr.inra.maiage.bibliome.util.biotopes2012;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import fr.inra.maiage.bibliome.util.Pair;
import fr.inra.maiage.bibliome.util.Strings;
import fr.inra.maiage.bibliome.util.clio.CLIOException;
import fr.inra.maiage.bibliome.util.clio.CLIOParser;
import fr.inra.maiage.bibliome.util.clio.CLIOption;
import fr.inra.maiage.bibliome.util.fragments.Fragment;

public class Biotopes2012Diff extends CLIOParser {
	private final List<String> documentDescriptions = new ArrayList<String>();
	private String url = "jdbc:postgresql://bddev:5432/annotation";
	private String schema = "aae_biotopes";
	private String user = "annotation_admin";
	private String password = "annotdba84";
	private String campaignName1 = "Annotateur 1";
	private String campaignName2 = "Annotateur 2";
	private boolean diffGroups = false;
	private boolean diffRelations = false;
	private boolean showMatchTextBound = false;
	private String annotator1 = "Annotateur 1";
	private String annotator2 = "Annotateur 2";
	private Integer firstXhead = null;

	private final Comparator<AlvisAEDocument> DOCUMENT_COMPARATOR = new Comparator<AlvisAEDocument>() {
		@Override
		public int compare(AlvisAEDocument a, AlvisAEDocument b) {
			return a.getDescription().compareTo(a.getDescription());
		}
	};

	public void diff(AlvisAECampaign campaign1, AlvisAECampaign campaign2) {
		List<AlvisAEDocument> documents = new ArrayList<AlvisAEDocument>(campaign1.getDocuments());
		Collections.sort(documents, DOCUMENT_COMPARATOR);
		for (AlvisAEDocument document1 : documents)
			diff(document1, campaign2.getDocumentByDescription(document1.getDescription()));
	}

	private void diff(AlvisAEDocument document1, AlvisAEDocument document2) {
		line(0, "
" + document1.getDescription() + "
");
		line(0, "Annotateur 1: " + annotator1 + "
");
		line(0, "Annotateur 2: " + annotator2 + "
");
		AlvisAEAnnotationSet aset1 = document1.getAnnotationSets().iterator().next();
		AlvisAEAnnotationSet aset2 = document2.getAnnotationSets().iterator().next();
		BiMap<TextBound,TextBound> textMap = diff(aset1.getTextBound(), aset2.getTextBound());
		if (diffGroups) {
			line(1, "
Check: groups contains only text-bound items in " + annotator1 + "
");
			checkAllTextBound(aset1);
			line(1, "
Check: groups contains only text-bound items in " + annotator2 + "
");
			checkAllTextBound(aset2);
			Map<TextBound,Group> groupMap = new HashMap<TextBound,Group>();
			line(1, "
Check: groups are exclusive in " + annotator1 + "
");
			mergeGroups(aset1, groupMap);
			line(1, "
Check: groups are exclusive in " + annotator2 + "
");
			mergeGroups(aset2, groupMap);
			diff(textMap, aset1.getGroups(), aset2.getGroups());
			if (diffRelations)
				diff(textMap, groupMap, aset1.getRelations(), aset2.getRelations());
		}
		ln();
	}

	private void diff(BiMap<TextBound,TextBound> textMap, Map<TextBound,Group> groupMap, Collection<Relation> rels1, Collection<Relation> rels2) {
		line(1, "
Relations
");
		line(1, "

Type/Role	" + annotator1 + "	" + annotator2 + "
");
		for (Relation r1 : rels1)
			if (!hasMatch(textMap, false, groupMap, r1, rels2)) {
				line(2, "
" + r1.getType() + "	" + r1.getId() + "
");
				for (String role : r1.getRoles())
					line(2, "
" + role + "	" + textCell(r1.getArgument(role)) + textCell(textMap.getForth(DownCastAnnotation.toTextBound(r1.getArgument(role)))) + "
");
			}
		for (Relation r2 : rels2)
			if (!hasMatch(textMap, true, groupMap, r2, rels1)) {
				line(2, "
" + r2.getType() + "		" + r2.getId() + "
");
				for (String role : r2.getRoles())
					line(2, "
" + role + "	" + textCell(textMap.getBack(DownCastAnnotation.toTextBound(r2.getArgument(role)))) + textCell(r2.getArgument(role)) + "
");
			}
		line(1, "
");
	}

	private boolean hasMatch(BiMap<TextBound,TextBound> textMap, boolean back, Map<TextBound,Group> groupMap, Relation r, Collection<Relation> rels) {
		for (Relation r2 : rels)
			if (match(textMap, back, groupMap, r, r2))
				return true;
		return false;
	}

	private boolean match(BiMap<TextBound,TextBound> textMap, boolean back, Map<TextBound,Group> groupMap, Relation r1, Relation r2) {
		if (!r1.getType().equals(r2.getType())) {
			return false;
		}
		Collection<String> roles1 = r1.getRoles();
		Collection<String> roles2 = r2.getRoles();
		if (!(roles1.containsAll(roles2) && roles2.containsAll(roles1))) {
			return false;
		}
		for (String role : roles1) {
			TextBound t1 = DownCastAnnotation.toTextBound(r1.getArgument(role));
			if (t1 == null) {
				return false;
			}
			TextBound t2 = DownCastAnnotation.toTextBound(r2.getArgument(role));
			if (t2 == null) {
				return false;
			}
			if (!isArgEquivalent(textMap, back, groupMap, t1, t2)) {
				return false;
			}
		}
		return true;
	}

	private boolean isArgEquivalent(BiMap<TextBound,TextBound> textMap, boolean back, Map<TextBound,Group> groupMap, TextBound t1, TextBound t2) {
		Group g1 = groupMap.get(t1);
		Group g2 = groupMap.get(t2);
		if (g1 == null) {
			if (g2 == null) {
				if (back)
					return textMap.hasPair(t2, t1);
				return textMap.hasPair(t1, t2);
			}
			if (back)
				return g2.getItems().contains(textMap.getBack(t1));
			return g2.getItems().contains(textMap.getForth(t1));
		}
		if (g2 == null) {
			if (back)
				return g1.getItems().contains(textMap.getBack(t2));
			return g1.getItems().contains(textMap.getForth(t2));
		}
		if (back)
			return groupDiff(textMap, g2, g1).hasCommon();
		return groupDiff(textMap, g1, g2).hasCommon();
	}

	private void diff(BiMap<TextBound,TextBound> textMap, Collection<Group> groups1, Collection<Group> groups2) {
		line(1, "
Groups
");
		line(1, "

" + annotator1 + "	Status	" + annotator2 + "
");
		Set<Group> hasSomething = new HashSet<Group>();
		for (Group group1 : groups1) {
			for (Group group2 : groups2) {
				GroupDiff diff = groupDiff(textMap, group1, group2);
				if (diff.hasCommon()) {
					hasSomething.add(group1);
					hasSomething.add(group2);
					//if (diff.isMatch())
					//	continue;
					line(2, "
" + group1 + "		" + group2 + "
");
					for (Pair<TextBound,TextBound> p : diff.missing)
						line(2, "
" + textCell(p.first) + "" + annotator1 + " only	" + textCell(p.second) + "
");
					for (Pair<TextBound,TextBound> p : diff.common)
						line(2, "
" + textCell(p.first) + "match	" + textCell(p.second) + "
");
					for (Pair<TextBound,TextBound> p : diff.extra)
						line(2, "
" + textCell(p.first) + "" + annotator2 + " only	" + textCell(p.second) + "
");
				}
			}
		}
		for (Group group : groups1)
			if (!hasSomething.contains(group)) {
				line(2, "
" + group + "
");
				for (AlvisAEAnnotation item : group.getItems()) {
					TextBound tb = DownCastAnnotation.toTextBound(item);
					if (tb == null)
						continue;
					line(2, "
" + textCell(tb) + "
");
				}
			}
		for (Group group : groups2)
			if (!hasSomething.contains(group)) {
				line(2, "
		" + group + "
");
				for (AlvisAEAnnotation item : group.getItems()) {
					TextBound tb = DownCastAnnotation.toTextBound(item);
					if (tb == null)
						continue;
					line(2, "
		" + textCell(tb) + "
");
				}
			}
		line(1, "
");
	}

	private class GroupDiff {
		private final Collection<Pair<TextBound,TextBound>> missing = new HashSet<Pair<TextBound,TextBound>>();
		private final Collection<Pair<TextBound,TextBound>> common = new HashSet<Pair<TextBound,TextBound>>();
		private final Collection<Pair<TextBound,TextBound>> extra = new HashSet<Pair<TextBound,TextBound>>();

		private boolean hasCommon() {
			return !common.isEmpty();
		}

		//		private boolean isMatch() {
		//			return hasCommon() && missing.isEmpty() && extra.isEmpty();
		//		}
	}

	private GroupDiff groupDiff(BiMap<TextBound,TextBound> textMap, Group group1, Group group2) {
		GroupDiff result = new GroupDiff();
		Collection<TextBound> items1 = getTextBound(group1);
		Collection<TextBound> items2 = getTextBound(group2);
		for (TextBound t1 : items1) {
			TextBound t2 = textMap.getForth(t1);
			if (t2 == null)
				continue;
			Pair<TextBound,TextBound> p = new Pair<TextBound,TextBound>(t1,t2);
			if (items2.contains(t2))
				result.common.add(p);
			else
				result.missing.add(p);
		}
		for (TextBound t2 : items2) {
			TextBound t1 = textMap.getBack(t2);
			if (t1 == null)
				continue;
			if (!items1.contains(t1))
				result.extra.add(new Pair<TextBound,TextBound>(t1, t2));
		}
		return result;
	}

	private static Collection<TextBound> getTextBound(Group group) {
		Collection<TextBound> result = new HashSet<TextBound>();
		for (AlvisAEAnnotation a : group.getItems()) {
			TextBound t = DownCastAnnotation.toTextBound(a);
			if (t != null)
				result.add(t);
		}
		return result;
	}

	private static void checkAllTextBound(AlvisAEAnnotationSet aset) {
		Collection<Group> toRemove = new HashSet<Group>();
		line(2, "
");
		for (Group group : aset.getGroups()) {
			line(3, "
" + group + "
");
			int n = checkAllTextBound(group);
			if (n == 0) {
				line(3, "
EMPTY: removed
");
				toRemove.add(group);
			}
		}
		for (Group g : toRemove)
			aset.removeGroup(g);
		line(2, "
");
	}

	private static int checkAllTextBound(Group group) {
		int result = 0;
		for (AlvisAEAnnotation a : group.getItems()) {
			if (DownCastAnnotation.toTextBound(a) == null) {
				line(3, "
not text-bound: " + a + "
");
			}
			else
				result++;
		}
		return result;
	}

	private static void mergeGroups(AlvisAEAnnotationSet aset, Map<TextBound,Group> groupMap) {
		line(2, "
");
		line(3, "
First merged	Second merged	Common item	Merged type	Merged ID
");
		while (true) {
			GroupMerge pair = needsMerge(aset, groupMap);
			if (pair == null)
				break;
			String mergedType = pair.first.getType();
			if (!mergedType.equals(pair.second.getType()))
				mergedType = mergedType + " / " + pair.second.getType();
			String mergedId = pair.first.getId() + '/' + pair.second.getId();
			line(3, "
" + pair.first + "	" + pair.second + "	" + pair.common + "	" + mergedType + "	" + mergedId + "
");
			Group merge = new Group(aset, mergedId, pair.first.getType());
			for (AlvisAEAnnotation a : pair.first.getItems())
				merge.addItem(a);
			for (AlvisAEAnnotation a : pair.second.getItems())
				merge.addItem(a);
			aset.removeGroup(pair.first);
			aset.removeGroup(pair.second);
			for (Map.Entry<TextBound,Group> e : groupMap.entrySet()) {
				if (e.getValue() == pair.first || e.getValue() == pair.second)
					e.setValue(merge);
			}
		}
		line(2, "
");
	}

	private static class GroupMerge extends Pair<Group,Group> {
		private final TextBound common;

		private GroupMerge(Group first, Group second, TextBound common) {
			super(first, second);
			this.common = common;
		}
	}

	private static GroupMerge needsMerge(AlvisAEAnnotationSet aset, Map<TextBound,Group> groupMap) {
		for (Group group : aset.getGroups()) {
			for (TextBound t : getTextBound(group)) {
				Group g = groupMap.get(t);
				if (g == null) {
					groupMap.put(t, group);
					continue;
				}
				if (g == group)
					continue;
				return new GroupMerge(group, g, t);
			}
		}
		return null;
	}

	private static final Comparator<TextBound> TEXT_BOUND_COMPARATOR = new Comparator<TextBound>() {
		@Override
		public int compare(TextBound a, TextBound b) {
			return a.getFragments()[0].getStart() - b.getFragments()[0].getStart();
		}
	};

	private static void line(int indent, Object msg) {
		for (int i = 0; i < indent; ++i)
			System.out.print("    ");
		System.out.println(msg);
	}

	private static void ln() {
		System.out.println();
	}

	private static String textCell(AlvisAEAnnotation a) {
		TextBound t = DownCastAnnotation.toTextBound(a);
		String form = t.getForm();
		if (form.length() > 80)
			form = form.substring(0, form.indexOf(' ')) + " BLA BLA BLA " + form.substring(form.lastIndexOf(' '));
		return "" + form + "	";
	}

	private BiMap<TextBound,TextBound> diff(Collection<TextBound> textBound1, Collection<TextBound> textBound2) {
		line(1, "
Text-bound annotations
");
		line(1, "

" + annotator1 + "	" + annotator2 + "	Status
");
		BiMap<TextBound,TextBound> result = new BiMap<TextBound,TextBound>();
		List<TextBound> rest1 = new ArrayList<>(textBound1);
		Collections.sort(rest1, TEXT_BOUND_COMPARATOR);
		Set<TextBound> rest2 = new HashSet<>(textBound2);
		for (TextBound t1 : rest1) {
			TextBound best = null;
			double score = 0;
			for (TextBound t2 : rest2) {
				double d = diff(t1, t2);
				if (d > score) {
					score = d;
					best = t2;
				}
			}
			if (best == null) {
				//				line(2, t1);
				//				line(2, "[MISSING]");
				//				ln();
				line(2, "
" + textCell(t1) + "	MISS
");
			}
			else {
				result.add(t1, best);
				rest2.remove(best);
				if (score == 1) {
					if (!t1.getType().equals(best.getType())) {
						//						line(2, t1);
						//						line(2, best);
						//						line(2, "[TYPE: " + t1.getType() + " / " + best.getType() + ']');
						//						ln();
						line(2, "
" + textCell(t1) + textCell(best) + "TYPE
");
					}
					else if (showMatchTextBound) {
						line(2, "
" + textCell(t1) + textCell(best) + "PERFECT
");
						//						line(2, t1);
						//						line(2, best);
						//						ln();
					}
				}
				else {
					line(2, "
" + textCell(t1) + textCell(best) + "BOUNDARIES " + (t1.getType().equals(best.getType()) ? "" : " & TYPE") + "
");
					//					line(2, t1);
					//					line(2, best);
					//					line(2, "[BOUNDARIES: " + score + ']');
					//					if (!t1.getType().equals(best.getType()))
					//						line(2, "[TYPE: " + t1.getType() + " / " + best.getType() + ']');
					//					ln();
				}
			}
		}
		for (TextBound t2 : rest2) {
			line(2, "
	" + textCell(t2) + "MISS
");
			//			line(2, "[EXTRA]");
			//			line(2, t2);
			//			ln();
		}
		line(1, "
");
		return result;
	}

	private static double diff(TextBound t1, TextBound t2) {
		double l = t1.getTotalLength() + t2.getTotalLength();
		Fragment[] frags1 = t1.getFragments();
		int overlap = 0;
		for (Fragment f2 : t2.getFragments())
			for (Fragment f1 : frags1)
				overlap += overlap(f1, f2);
		return overlap / (l - overlap);
	}

	private static int overlap(Fragment f1, Fragment f2) {
		if (f1.getEnd() < f2.getStart())
			return 0;
		if (f2.getEnd() < f1.getStart())
			return 0;
		return Math.min(f1.getEnd(), f2.getEnd()) - Math.max(f1.getStart(), f2.getStart());
	}

	public static void main(String[] args) throws SQLException, ClassNotFoundException, CLIOException {
		Biotopes2012Diff inst = new Biotopes2012Diff();
		if (inst.parse(args))
			return;
		AlvisAECampaign campaign1 = new AlvisAECampaign(inst.firstXhead == null ? 4 : inst.firstXhead, inst.campaignName1);
		AlvisAECampaign campaign2 = new AlvisAECampaign(inst.firstXhead == null ? 5 : inst.firstXhead, inst.campaignName2);
		Class.forName("org.postgresql.Driver");
		try (Connection connection = DriverManager.getConnection(inst.url, inst.user, inst.password)) {
			campaign1.load(connection, inst.schema, 1, inst.documentDescriptions, inst.firstXhead != null);
			campaign2.load(connection, inst.schema, 1, inst.documentDescriptions, false);
			inst.diff(campaign1, campaign2);
		}
	}

	@Override
	protected boolean processArgument(String arg) throws CLIOException {
		documentDescriptions.add(arg);
		return false;
	}

	@Override
	public String getResourceBundleName() {
		return Biotopes2012Diff.class.getCanonicalName() + "Help";
	}

	@CLIOption("-firstXhead")
	public void setFirstXHead(int campaign) {
		this.firstXhead = campaign;
	}

	@CLIOption("-groups")
	public void setDiffGroups() {
		this.diffGroups = true;
	}

	@CLIOption("-relations")
	public void setDiffRelations() {
		this.diffRelations = true;
		this.diffGroups = true;
	}

	@CLIOption("-show-text-matches")
	public void setShowMatchTextBound() {
		this.showMatchTextBound = true;
	}

	@CLIOption("-annotator1")
	public void setAnnotator1(String annotator1) {
		this.annotator1 = annotator1;
	}

	@CLIOption("-annotator2")
	public void setAnnotator2(String annotator2) {
		this.annotator2 = annotator2;
	}
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Cenangium raineri De Not.

### Remarks
null


text:
import { Router } from 'express'

const router = Router()

// For our SPA
router.get('*', (req, res, next) => {
  res.render('index', {
    title: 'React Bible Boilerplate'
  })
})

export default router


text:
<?php
namespace Xt\Util;
class PHP extends Version{
    public $downloadUrl = "http://php.net/downloads.php";
    public $formatRegex = "php-([0-9]+.[0-9]+.[0-9]+).tar.gz";
    public function getVersions($DownloadUrl = null, $formatRegex = null, $getNewVersion = false,$isStripTags=false){
        $DownloadUrl = is_null($DownloadUrl)?$this->downloadUrl:$formatRegex;
        $formatRegex = is_null($formatRegex)?$this->formatRegex:$formatRegex;
        if($this->version!=null){
            $vv = explode(".",$this->version);
            $v = current($vv);
            $allow = ['4','5','7'];
            if(in_array($v,$allow)){
                $DownloadUrl = "http://php.net/ChangeLog-{$v}.php";
                $formatRegex = "Version ({$this->version}[a-zA-Z0-9.]+)";
            }else{
                $formatRegex = "php-({$this->version}[a-zA-Z0-9.]+).tar.gz";
            }
        }
        return parent::getVersions($DownloadUrl, $formatRegex, $getNewVersion);
    }

    public function getNewVersion($DownloadUrl = null, $formatRegex = null){
        return $this->getVersions($DownloadUrl,$formatRegex,true);
    }
}
?>


text:
shady
=====

cyber shady sniffer


text:
require 'spec_helper'

describe Riddle::Client do
  describe '#initialize' do
    it "should check the loaded Sphinx version" do
      Riddle.should_receive(:version_warning)

      Riddle::Client.new
    end
  end
end


text:
package io.github.ibuildthecloud.gdapi.util;

public class ExceptionUtils {

    @SuppressWarnings("unchecked")
    public static <T extends Throwable> void rethrow(Throwable t, Class<T> clz) throws T {
        if (clz.isAssignableFrom(t.getClass()))
            throw (T)t;
    }

    public static <T extends Throwable> void rethrowRuntime(Throwable t) {
        rethrow(t, RuntimeException.class);
        rethrow(t, Error.class);
    }

}


text:
package dbfakes

import (
	"sync"

	"github.com/concourse/concourse/atc/db"
)

type FakeDestroyingVolume struct {
	DestroyStub        func() (bool, error)
	destroyMutex       sync.RWMutex
	destroyArgsForCall []struct {
	}
	destroyReturns struct {
		result1 bool
		result2 error
	}
	destroyReturnsOnCall map[int]struct {
		result1 bool
		result2 error
	}
	HandleStub        func() string
	handleMutex       sync.RWMutex
	handleArgsForCall []struct {
	}
	handleReturns struct {
		result1 string
	}
	handleReturnsOnCall map[int]struct {
		result1 string
	}
	WorkerNameStub        func() string
	workerNameMutex       sync.RWMutex
	workerNameArgsForCall []struct {
	}
	workerNameReturns struct {
		result1 string
	}
	workerNameReturnsOnCall map[int]struct {
		result1 string
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeDestroyingVolume) Destroy() (bool, error) {
	fake.destroyMutex.Lock()
	ret, specificReturn := fake.destroyReturnsOnCall[len(fake.destroyArgsForCall)]
	fake.destroyArgsForCall = append(fake.destroyArgsForCall, struct {
	}{})
	stub := fake.DestroyStub
	fakeReturns := fake.destroyReturns
	fake.recordInvocation("Destroy", []interface{}{})
	fake.destroyMutex.Unlock()
	if stub != nil {
		return stub()
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeDestroyingVolume) DestroyCallCount() int {
	fake.destroyMutex.RLock()
	defer fake.destroyMutex.RUnlock()
	return len(fake.destroyArgsForCall)
}

func (fake *FakeDestroyingVolume) DestroyCalls(stub func() (bool, error)) {
	fake.destroyMutex.Lock()
	defer fake.destroyMutex.Unlock()
	fake.DestroyStub = stub
}

func (fake *FakeDestroyingVolume) DestroyReturns(result1 bool, result2 error) {
	fake.destroyMutex.Lock()
	defer fake.destroyMutex.Unlock()
	fake.DestroyStub = nil
	fake.destroyReturns = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeDestroyingVolume) DestroyReturnsOnCall(i int, result1 bool, result2 error) {
	fake.destroyMutex.Lock()
	defer fake.destroyMutex.Unlock()
	fake.DestroyStub = nil
	if fake.destroyReturnsOnCall == nil {
		fake.destroyReturnsOnCall = make(map[int]struct {
			result1 bool
			result2 error
		})
	}
	fake.destroyReturnsOnCall[i] = struct {
		result1 bool
		result2 error
	}{result1, result2}
}

func (fake *FakeDestroyingVolume) Handle() string {
	fake.handleMutex.Lock()
	ret, specificReturn := fake.handleReturnsOnCall[len(fake.handleArgsForCall)]
	fake.handleArgsForCall = append(fake.handleArgsForCall, struct {
	}{})
	stub := fake.HandleStub
	fakeReturns := fake.handleReturns
	fake.recordInvocation("Handle", []interface{}{})
	fake.handleMutex.Unlock()
	if stub != nil {
		return stub()
	}
	if specificReturn {
		return ret.result1
	}
	return fakeReturns.result1
}

func (fake *FakeDestroyingVolume) HandleCallCount() int {
	fake.handleMutex.RLock()
	defer fake.handleMutex.RUnlock()
	return len(fake.handleArgsForCall)
}

func (fake *FakeDestroyingVolume) HandleCalls(stub func() string) {
	fake.handleMutex.Lock()
	defer fake.handleMutex.Unlock()
	fake.HandleStub = stub
}

func (fake *FakeDestroyingVolume) HandleReturns(result1 string) {
	fake.handleMutex.Lock()
	defer fake.handleMutex.Unlock()
	fake.HandleStub = nil
	fake.handleReturns = struct {
		result1 string
	}{result1}
}

func (fake *FakeDestroyingVolume) HandleReturnsOnCall(i int, result1 string) {
	fake.handleMutex.Lock()
	defer fake.handleMutex.Unlock()
	fake.HandleStub = nil
	if fake.handleReturnsOnCall == nil {
		fake.handleReturnsOnCall = make(map[int]struct {
			result1 string
		})
	}
	fake.handleReturnsOnCall[i] = struct {
		result1 string
	}{result1}
}

func (fake *FakeDestroyingVolume) WorkerName() string {
	fake.workerNameMutex.Lock()
	ret, specificReturn := fake.workerNameReturnsOnCall[len(fake.workerNameArgsForCall)]
	fake.workerNameArgsForCall = append(fake.workerNameArgsForCall, struct {
	}{})
	stub := fake.WorkerNameStub
	fakeReturns := fake.workerNameReturns
	fake.recordInvocation("WorkerName", []interface{}{})
	fake.workerNameMutex.Unlock()
	if stub != nil {
		return stub()
	}
	if specificReturn {
		return ret.result1
	}
	return fakeReturns.result1
}

func (fake *FakeDestroyingVolume) WorkerNameCallCount() int {
	fake.workerNameMutex.RLock()
	defer fake.workerNameMutex.RUnlock()
	return len(fake.workerNameArgsForCall)
}

func (fake *FakeDestroyingVolume) WorkerNameCalls(stub func() string) {
	fake.workerNameMutex.Lock()
	defer fake.workerNameMutex.Unlock()
	fake.WorkerNameStub = stub
}

func (fake *FakeDestroyingVolume) WorkerNameReturns(result1 string) {
	fake.workerNameMutex.Lock()
	defer fake.workerNameMutex.Unlock()
	fake.WorkerNameStub = nil
	fake.workerNameReturns = struct {
		result1 string
	}{result1}
}

func (fake *FakeDestroyingVolume) WorkerNameReturnsOnCall(i int, result1 string) {
	fake.workerNameMutex.Lock()
	defer fake.workerNameMutex.Unlock()
	fake.WorkerNameStub = nil
	if fake.workerNameReturnsOnCall == nil {
		fake.workerNameReturnsOnCall = make(map[int]struct {
			result1 string
		})
	}
	fake.workerNameReturnsOnCall[i] = struct {
		result1 string
	}{result1}
}

func (fake *FakeDestroyingVolume) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.destroyMutex.RLock()
	defer fake.destroyMutex.RUnlock()
	fake.handleMutex.RLock()
	defer fake.handleMutex.RUnlock()
	fake.workerNameMutex.RLock()
	defer fake.workerNameMutex.RUnlock()
	copiedInvocations := map[string][][]interface{}{}
	for key, value := range fake.invocations {
		copiedInvocations[key] = value
	}
	return copiedInvocations
}

func (fake *FakeDestroyingVolume) recordInvocation(key string, args []interface{}) {
	fake.invocationsMutex.Lock()
	defer fake.invocationsMutex.Unlock()
	if fake.invocations == nil {
		fake.invocations = map[string][][]interface{}{}
	}
	if fake.invocations[key] == nil {
		fake.invocations[key] = [][]interface{}{}
	}
	fake.invocations[key] = append(fake.invocations[key], args)
}

var _ db.DestroyingVolume = new(FakeDestroyingVolume)


text:
module Postfiks
  # An implementation of a reverse Polish notation parser
  class Parser
    attr_reader :tokens, :stack

    # Initializes an empty Stack and tokenizes given string
    #
    # @param string [String] string to be tokenized
    def initialize(string)
      @tokens = Tokenizer.new
      @tokens = @tokens.tokenize(string)
      @stack = Stack.new
    end

    # Evalutes the tokenized objects
    #
    # @return [Numeric] numerical result
    # @raise [InsufficientValuesInExpression]
    # @raise [InvalidExpression]
    def evaluate
      @tokens.each do |token|
        if token.is_a? Operand
          @stack << token.value
        elsif token.is_a? Operator
          fail InsufficientValuesInExpression if @stack.size < 2
          @stack << @stack.pop(2).reduce(token.type)
        end
      end

      fail InvalidExpression if @stack.size > 1
      @stack.peek
    end
  end
end


text:
package me.sniggle.matemonkey4j.robospice.producer;

import me.sniggle.matemonkey4j.api.model.result.ProducerResult;
import me.sniggle.matemonkey4j.producer.ProducersCallable;
import me.sniggle.matemonkey4j.robospice.BaseMateMonkeyRequest;

/**
 * @author tuxbox, sniggle.me
 *
 * Request wrapper for ProducersCallable
 */
public class ProducersRequest extends BaseMateMonkeyRequest<ProducerResult> {

  /**
   * default constructor requesting all producers
   */
  public ProducersRequest() {
    super(ProducerResult.class, new ProducersCallable());
  }

}


text:
UvPoller::UvPoller(
  int descriptor,
  void (*read_ready_callback)(void *data),
  void (*write_ready_callback)(void *data),
  void (*error_callback)(void *data, const char *error),
  void *external_data
) {}

UvPoller::~UvPoller(void) {}

void UvPoller::on_close(uv_handle_t *handle) {}

void UvPoller::io_event_wrapper(uv_poll_t *watcher, int status, int revents) {}

void UvPoller::io_event(int status, int revents) {}

void UvPoller::set_events(PollerEvents events) {
  mock().actualCall("set_events").withIntParameter("events", events);
}