diff --git a/headers/Containers/Concepts.hpp b/headers/Containers/Concepts.hpp deleted file mode 100644 index c144e11..0000000 --- a/headers/Containers/Concepts.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: Dora "cat" - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef GUARD_TOURMALINE_CONCEPTS_H -#define GUARD_TOURMALINE_CONCEPTS_H -#include -#include - -namespace Tourmaline::Containers { -template -concept Hashable = std::equality_comparable && requires(T x) { - { std::hash{}(x) } -> std::convertible_to; -}; - -template -concept Either = std::same_as || std::same_as; -} // namespace Tourmaline::Containers -#endif diff --git a/headers/Containers/DualkeyMap.hpp b/headers/Containers/DualkeyMap.hpp index 08dc49b..6b8d22d 100644 --- a/headers/Containers/DualkeyMap.hpp +++ b/headers/Containers/DualkeyMap.hpp @@ -8,8 +8,8 @@ */ #ifndef GUARD_TOURMALINE_DUALKEYMAP_H #define GUARD_TOURMALINE_DUALKEYMAP_H +#include "../Concepts.hpp" #include "../Systems/Logging.hpp" -#include "Concepts.hpp" #include #include @@ -25,17 +25,16 @@ #include namespace Tourmaline::Containers { -template class DualkeyMap { public: // Return Types - template - requires Either + template + requires Concepts::Either using MultiQueryResult = - std::pair, - std::array, resultValueCount>>; + std::pair, Count>>; using QueryResult = std::pair, std::reference_wrapper>, @@ -197,17 +196,19 @@ public: return finishedQuery; } - template - requires Either + template , + std::size_t keyCount> + requires Concepts::Either [[nodiscard("Discarding a very expensive query!")]] int QueryWithAll(const Key (&keys)[keyCount]) { - auto queryResults = queryWithMany(keys); + std::vector> + queryResults = queryWithMany(keys); // You could very well use auto here but this helps // with LSP hints - for (const unprocessedMultiQueryResult< - std::conditional_t, BKey, AKey>, - keyCount> &queryRecord : queryResults) { + for (const unprocessedMultiQueryResult &queryRecord : + queryResults) { if (queryRecord.howManyFound == keyCount) { } } @@ -269,9 +270,10 @@ private: std::stack graveyard; // Interal querying - template - inline std::vector, BKey, AKey>, keyCount>> + template , + std::size_t keyCount> + inline std::vector> queryWithMany(const Key (&keys)[keyCount]) { constexpr bool searchingInFirstKey = std::is_same_v; @@ -299,10 +301,10 @@ private: uint64_t hashToCompare; Key *keyToCompare; - std::conditional_t resultKey; - std::vector, keyCount>> + OppositeKey *resultKey; + std::vector> queryResults; + for (DualkeyHash *hash : hashList) { // The hell of doing 2 conditions with similar logics in // the same logical block