Delete unused class PairHash
Partial revert of https://webrtc-review.googlesource.com/c/src/+/216243, this class is no longer needed, after https://webrtc-review.googlesource.com/c/src/+/229182 replaced usage of unordered_map with flat_map. Bug: webrtc:12689 Change-Id: I56e4d9326334b78eb09d471ded752e58601f4abf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231235 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Victor Boivie <boivie@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34941}
This commit is contained in:
parent
61a5bcbaa1
commit
bc93575749
@ -119,7 +119,6 @@ rtc_library("rtc_base_approved") {
|
||||
"copy_on_write_buffer.h",
|
||||
"event_tracer.cc",
|
||||
"event_tracer.h",
|
||||
"hash.h",
|
||||
"location.cc",
|
||||
"location.h",
|
||||
"numerics/histogram_percentile_counter.cc",
|
||||
@ -1351,7 +1350,6 @@ if (rtc_include_tests) {
|
||||
"deprecated/recursive_critical_section_unittest.cc",
|
||||
"event_tracer_unittest.cc",
|
||||
"event_unittest.cc",
|
||||
"hash_unittest.cc",
|
||||
"logging_unittest.cc",
|
||||
"numerics/divide_round_unittest.cc",
|
||||
"numerics/histogram_percentile_counter_unittest.cc",
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef RTC_BASE_HASH_H_
|
||||
#define RTC_BASE_HASH_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// A custom hash function for std::pair, to be able to be used as key in a
|
||||
// std::unordered_map. If absl::flat_hash_map would ever be used, this is
|
||||
// unnecessary as it already has a hash function for std::pair.
|
||||
struct PairHash {
|
||||
template <class T1, class T2>
|
||||
size_t operator()(const std::pair<T1, T2>& p) const {
|
||||
return (3 * std::hash<T1>{}(p.first)) ^ std::hash<T2>{}(p.second);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // RTC_BASE_HASH_H_
|
||||
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "rtc_base/hash.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
TEST(PairHashTest, CanInsertIntoSet) {
|
||||
using MyPair = std::pair<int, int>;
|
||||
|
||||
std::unordered_set<MyPair, PairHash> pairs;
|
||||
|
||||
pairs.insert({1, 2});
|
||||
pairs.insert({3, 4});
|
||||
|
||||
EXPECT_NE(pairs.find({1, 2}), pairs.end());
|
||||
EXPECT_NE(pairs.find({3, 4}), pairs.end());
|
||||
EXPECT_EQ(pairs.find({1, 3}), pairs.end());
|
||||
EXPECT_EQ(pairs.find({3, 3}), pairs.end());
|
||||
}
|
||||
|
||||
TEST(PairHashTest, CanInsertIntoMap) {
|
||||
using MyPair = std::pair<std::string, int>;
|
||||
|
||||
std::unordered_map<MyPair, int, PairHash> pairs;
|
||||
|
||||
pairs[{"1", 2}] = 99;
|
||||
pairs[{"3", 4}] = 100;
|
||||
|
||||
EXPECT_EQ((pairs[{"1", 2}]), 99);
|
||||
EXPECT_EQ((pairs[{"3", 4}]), 100);
|
||||
EXPECT_EQ(pairs.find({"1", 3}), pairs.end());
|
||||
EXPECT_EQ(pairs.find({"3", 3}), pairs.end());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
Loading…
x
Reference in New Issue
Block a user