Skip to content

Commit

Permalink
feat: implement more stl wrappers (#648)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuchen Liang <[email protected]>
  • Loading branch information
yliang412 authored Nov 4, 2023
1 parent d6170fd commit 818c5df
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/include/storage/index/stl_equal_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

namespace bustub {

template <typename K, typename KC>
class StlEqualWrapper {
public:
explicit StlEqualWrapper(const KC &cmp) : cmp_{cmp} {}

inline auto operator()(const K &lhs, const K &rhs) const -> bool { return cmp_(lhs, rhs) == 0; }

KC cmp_;
};

} // namespace bustub
17 changes: 17 additions & 0 deletions src/include/storage/index/stl_hasher_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "container/hash/hash_function.h"

namespace bustub {

template <typename K>
class StlHasherWrapper {
public:
explicit StlHasherWrapper(const HashFunction<K> &hash_fn) : hash_fn_{hash_fn} {}

inline auto operator()(const K &key) const -> std::size_t { return hash_fn_.GetHash(key); }

HashFunction<K> hash_fn_;
};

} // namespace bustub

0 comments on commit 818c5df

Please sign in to comment.