Export of internal Abseil changes

--
4ee535c37f92cd45b8c9aa009e5c833265b3a0bb by Samuel Benzaquen <sbenza@google.com>:

Test and fix `insert(hint, node)`

PiperOrigin-RevId: 337122891

--
7b760ced555756fecbad702fedb697424dd65167 by Abseil Team <absl-team@google.com>:

Changed the minimum version of iOS and OSX for Abseil Podspec.

PiperOrigin-RevId: 336926756
GitOrigin-RevId: 4ee535c37f92cd45b8c9aa009e5c833265b3a0bb
Change-Id: I94e70f3342570c83b9965ca458a3f02eaa3efc0d
pull/827/head
Abseil Team 4 years ago committed by Derek Mauro
parent f3f785ab59
commit 60d00a5822
  1. 4
      absl/abseil.podspec.gen.py
  2. 4
      absl/container/internal/raw_hash_set.h
  3. 20
      absl/container/internal/raw_hash_set_test.cc

@ -40,8 +40,8 @@ Pod::Spec.new do |s|
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
}
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
s.watchos.deployment_target = '2.0'
"""

@ -1065,7 +1065,9 @@ class raw_hash_set {
}
iterator insert(const_iterator, node_type&& node) {
return insert(std::move(node)).first;
auto res = insert(std::move(node));
node = std::move(res.node);
return res.position;
}
// This overload kicks in if we can deduce the key from args. This enables us

@ -1711,6 +1711,26 @@ TEST(Nodes, ExtractInsert) {
EXPECT_FALSE(node);
}
TEST(Nodes, HintInsert) {
IntTable t = {1, 2, 3};
auto node = t.extract(1);
EXPECT_THAT(t, UnorderedElementsAre(2, 3));
auto it = t.insert(t.begin(), std::move(node));
EXPECT_THAT(t, UnorderedElementsAre(1, 2, 3));
EXPECT_EQ(*it, 1);
EXPECT_FALSE(node);
node = t.extract(2);
EXPECT_THAT(t, UnorderedElementsAre(1, 3));
// reinsert 2 to make the next insert fail.
t.insert(2);
EXPECT_THAT(t, UnorderedElementsAre(1, 2, 3));
it = t.insert(t.begin(), std::move(node));
EXPECT_EQ(*it, 2);
// The node was not emptied by the insert call.
EXPECT_TRUE(node);
}
IntTable MakeSimpleTable(size_t size) {
IntTable t;
while (t.size() < size) t.insert(t.size());

Loading…
Cancel
Save