-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement more stl wrappers (#648)
Signed-off-by: Yuchen Liang <[email protected]>
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |