Skip to content

Commit

Permalink
conceptEqualFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Oct 7, 2023
1 parent 1879167 commit 5c8ed5e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 22 additions & 18 deletions include/momo/HashSorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ class HashSorter
template<internal::conceptRandomIterator Iterator, typename ItemArg,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptHashFunc<Item> HashFunc = HashCoder<Item>,
internal::conceptEqualFunc<Item, ItemArg> EqualFunc = std::equal_to<>>
requires internal::conceptEqualFunc<EqualFunc, Item>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc = std::equal_to<>>
static FindResult<Iterator> Find(Iterator begin, size_t count,
const ItemArg& itemArg, HashCode argHash,
HashFunc hashFunc = HashFunc(), EqualFunc equalFunc = EqualFunc())
Expand All @@ -189,9 +188,8 @@ class HashSorter
template<internal::conceptRandomIterator Iterator, typename ItemArg,
internal::conceptRandomIterator HashIterator,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptEqualFunc<Item, ItemArg> EqualFunc = std::equal_to<>>
requires std::is_same_v<HashCode, std::iter_value_t<HashIterator>> &&
internal::conceptEqualFunc<EqualFunc, Item>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc = std::equal_to<>>
requires std::is_same_v<HashCode, std::iter_value_t<HashIterator>>
static FindResult<Iterator> FindPrehashed(Iterator begin, size_t count, const ItemArg& itemArg,
HashCode argHash, HashIterator hashBegin, EqualFunc equalFunc = EqualFunc())
{
Expand All @@ -203,8 +201,7 @@ class HashSorter
template<internal::conceptRandomIterator Iterator, typename ItemArg,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptHashFunc<Item> HashFunc = HashCoder<Item>,
internal::conceptEqualFunc<Item, ItemArg> EqualFunc = std::equal_to<>>
requires internal::conceptEqualFunc<EqualFunc, Item>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc = std::equal_to<>>
static Bounds<Iterator> GetBounds(Iterator begin, size_t count,
const ItemArg& itemArg, HashCode argHash,
HashFunc hashFunc = HashFunc(), EqualFunc equalFunc = EqualFunc())
Expand All @@ -217,9 +214,8 @@ class HashSorter
template<internal::conceptRandomIterator Iterator, typename ItemArg,
internal::conceptRandomIterator HashIterator,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptEqualFunc<Item, ItemArg> EqualFunc = std::equal_to<>>
requires std::is_same_v<HashCode, std::iter_value_t<HashIterator>> &&
internal::conceptEqualFunc<EqualFunc, Item>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc = std::equal_to<>>
requires std::is_same_v<HashCode, std::iter_value_t<HashIterator>>
static Bounds<Iterator> GetBoundsPrehashed(Iterator begin, size_t count, const ItemArg& itemArg,
HashCode argHash, HashIterator hashBegin, EqualFunc equalFunc = EqualFunc())
{
Expand All @@ -230,8 +226,9 @@ class HashSorter

private:
template<internal::conceptRandomIterator Iterator,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptConstFunctor<size_t, Iterator> IterHashFunc,
internal::conceptEqualFunc<std::iter_value_t<Iterator>> EqualFunc,
internal::conceptEqualFunc<Item> EqualFunc,
internal::conceptConstFunctor<void, Iterator, Iterator> IterSwapper>
static void pvSort(Iterator begin, size_t count, FastCopyableFunctor<IterHashFunc> iterHashFunc,
FastCopyableFunctor<EqualFunc> equalFunc, FastCopyableFunctor<IterSwapper> iterSwapper)
Expand All @@ -246,7 +243,8 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator,
internal::conceptEqualFunc<std::iter_value_t<Iterator>> EqualFunc,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptEqualFunc<Item> EqualFunc,
internal::conceptConstFunctor<void, Iterator, Iterator> IterSwapper>
static void pvGroup(Iterator begin, size_t count, FastCopyableFunctor<EqualFunc> equalFunc,
FastCopyableFunctor<IterSwapper> iterSwapper)
Expand All @@ -267,8 +265,9 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptConstFunctor<size_t, Iterator> IterHashFunc,
internal::conceptEqualFunc<std::iter_value_t<Iterator>> EqualFunc>
internal::conceptEqualFunc<Item> EqualFunc>
static bool pvIsSorted(Iterator begin, size_t count,
FastCopyableFunctor<IterHashFunc> iterHashFunc, FastCopyableFunctor<EqualFunc> equalFunc)
{
Expand All @@ -291,7 +290,8 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator,
internal::conceptEqualFunc<std::iter_value_t<Iterator>> EqualFunc>
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptEqualFunc<Item> EqualFunc>
static bool pvIsGrouped(Iterator begin, size_t count, FastCopyableFunctor<EqualFunc> equalFunc)
{
for (size_t i = 1; i < count; ++i)
Expand All @@ -308,8 +308,9 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator, typename ItemArg,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptConstFunctor<size_t, Iterator> IterHashFunc,
internal::conceptEqualFunc<std::iter_value_t<Iterator>, ItemArg> EqualFunc>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc>
static FindResult<Iterator> pvFind(Iterator begin, size_t count, const ItemArg& itemArg,
HashCode argHash, FastCopyableFunctor<IterHashFunc> iterHashFunc,
FastCopyableFunctor<EqualFunc> equalFunc)
Expand All @@ -328,8 +329,9 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator, typename ItemArg,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptConstFunctor<size_t, Iterator> IterHashFunc,
internal::conceptEqualFunc<std::iter_value_t<Iterator>, ItemArg> EqualFunc>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc>
static Bounds<Iterator> pvGetBounds(Iterator begin, size_t count, const ItemArg& itemArg,
HashCode argHash, FastCopyableFunctor<IterHashFunc> iterHashFunc,
FastCopyableFunctor<EqualFunc> equalFunc)
Expand Down Expand Up @@ -361,8 +363,9 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator, typename ItemArg,
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptConstFunctor<size_t, Iterator> IterHashFunc,
internal::conceptEqualFunc<std::iter_value_t<Iterator>, ItemArg> EqualFunc>
internal::conceptEqualFunc<Item, Item, ItemArg> EqualFunc>
static FindResult<Iterator> pvFindNext(Iterator begin, size_t count, const ItemArg& itemArg,
HashCode argHash, FastCopyableFunctor<IterHashFunc> iterHashFunc,
FastCopyableFunctor<EqualFunc> equalFunc)
Expand All @@ -380,7 +383,8 @@ class HashSorter
}

template<internal::conceptRandomIterator Iterator,
internal::conceptEqualFunc<std::iter_value_t<Iterator>> EqualFunc>
conceptObject Item = std::iter_value_t<Iterator>,
internal::conceptEqualFunc<Item> EqualFunc>
static Iterator pvFindOther(Iterator begin, size_t count,
FastCopyableFunctor<EqualFunc> equalFunc)
{
Expand Down
5 changes: 3 additions & 2 deletions include/momo/KeyUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ namespace momo
namespace internal
{
template<typename EqualFunc, typename Key,
typename KeyArg = Key>
concept conceptEqualFunc = conceptPredicate<EqualFunc, const Key&, const KeyArg&>;
typename KeyArg = Key, typename... KeyArgs>
concept conceptEqualFunc = conceptPredicate<EqualFunc, const Key&, const KeyArg&> &&
(conceptPredicate<EqualFunc, const Key&, const KeyArgs&> && ...);

template<typename LessFunc, typename Key>
concept conceptLessFunc = conceptPredicate<LessFunc, const Key&, const Key&>;
Expand Down

0 comments on commit 5c8ed5e

Please sign in to comment.