Skip to content

Commit

Permalink
add fast flat map feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arBmind committed Jun 2, 2024
1 parent 9dd66d1 commit eae9a75
Show file tree
Hide file tree
Showing 13 changed files with 892 additions and 379 deletions.
12 changes: 6 additions & 6 deletions src/array19.lib/array19/Zip.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ template<class A, class B> struct Zip {
};

constexpr Zip() = default;
constexpr explicit Zip(A& a, B& b) : a(&a), b(&b) {}
constexpr explicit Zip(A&& a, B&& b) : a{(A &&) a}, b{(B &&) b} {}

constexpr auto begin() const -> iterator { return {adlBegin(*a), adlBegin(*b)}; }
constexpr auto end() const -> iterator { return {adlEnd(*a), adlEnd(*b)}; }
constexpr auto begin() const -> iterator { return {adlBegin(a), adlBegin(b)}; }
constexpr auto end() const -> iterator { return {adlEnd(a), adlEnd(b)}; }

private:
A* a{};
B* b{};
A&& a{};
B&& b{};
};

template<class A, class B> Zip(A&, B&) -> Zip<A, B>;
template<class A, class B> Zip(A&&, B&&) -> Zip<A, B>;

} // namespace array19
6 changes: 3 additions & 3 deletions src/array19.lib/array19/adlRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

namespace array19 {

template<class T> constexpr auto adlBegin(T& v) {
template<class T> constexpr auto adlBegin(T&& v) {
using std::begin;
return begin(v);
}
template<class T> constexpr auto adlEnd(T& v) {
template<class T> constexpr auto adlEnd(T&& v) {
using std::end;
return end(v);
}

} // namespace array19
} // namespace array19
2 changes: 1 addition & 1 deletion src/array19.lib/array19/array19.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Product {
"AllocatedArrayUtils.h",
"Array.h",
"Array.ostream.h",
"DynamicArrayOf.AsHex.ostream.h",
"DynamicArray.AsHex.ostream.h",
"DynamicArray.equals.h",
"DynamicArray.h",
"DynamicArray.ostream.h",
Expand Down
12 changes: 12 additions & 0 deletions src/lookup19.lib/lookup19/OrderedMapArray.equals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include "OrderedMapArray.h"
#include "array19/Span.equals.h"

namespace lookup19 {

template<class Key, class Value, class Less>
bool operator==(const OrderedMapArray<Key, Value, Less>& a, const OrderedMapArray<Key, Value, Less>& b) {
return a.keys() == b.keys() && a.values() == b.values();
}

} // namespace lookup19
Loading

0 comments on commit eae9a75

Please sign in to comment.