Export of internal Abseil changes
-- 8e04df6fcbd062e5eaf179a6ec9b0a26f8aa8a39 by Abseil Team <absl-team@google.com>: Use a floating point type for the example usage of absl::uniform_real_distribution. PiperOrigin-RevId: 271167776 -- 5f8f1dfea50bc16a9d9af3e50c4636500a938b29 by Abseil Team <absl-team@google.com>: the llvm wasm backend does not support this data symbol in text section, so remove it from the test. PiperOrigin-RevId: 271138100 -- 2874542cb212962ac3093fd78fd5e1eb85c126c0 by Xiaoyi Zhang <zhangxy@google.com>: Work around MSVC 2019 compiler bug related to constexpr in optional_test. The change in optional_test is necessary to avoid another bug on MSVC complaining about accessing invalid member of union, and also makes the test more reasonale by checking the value of a non-static member. Filed a bug against MSVC https://developercommunity.visualstudio.com/content/problem/743998/internal-compiler-error-related-to-constexpr-and-u.html. PiperOrigin-RevId: 271129805 -- 3a5d56f0c3362aabf68938fb95c4e2d3eca59538 by Abseil Team <absl-team@google.com>: Improve precision of absl::GetCurrentTimeNanos() by adjusting cycle time sooner. PiperOrigin-RevId: 271007945 -- 1e044a6dec7c0ca150fff1aee52dbdb16aa43ed7 by Abseil Team <absl-team@google.com>: Internal change. PiperOrigin-RevId: 270962690 GitOrigin-RevId: 8e04df6fcbd062e5eaf179a6ec9b0a26f8aa8a39 Change-Id: Icb05423a7e93ebdae16baadd59a60b75b5cfa249
This commit is contained in:
parent
ccdd1d57b6
commit
502efe6d78
7 changed files with 23 additions and 11 deletions
|
@ -2239,6 +2239,13 @@ TEST(Btree, MoveAssignmentAllocatorPropagation) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(Btree, EmptyTree) {
|
||||
absl::btree_set<int> s;
|
||||
EXPECT_TRUE(s.empty());
|
||||
EXPECT_EQ(s.size(), 0);
|
||||
EXPECT_GT(s.max_size(), 0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace container_internal
|
||||
} // namespace absl
|
||||
|
|
|
@ -1226,7 +1226,7 @@ class btree {
|
|||
// The height of the btree. An empty tree will have height 0.
|
||||
size_type height() const {
|
||||
size_type h = 0;
|
||||
if (root()) {
|
||||
if (!empty()) {
|
||||
// Count the length of the chain from the leftmost node up to the
|
||||
// root. We actually count from the root back around to the level below
|
||||
// the root, but the calculation is the same because of the circularity
|
||||
|
@ -1277,16 +1277,17 @@ class btree {
|
|||
// divided by the maximum number of elements a tree with the current number
|
||||
// of nodes could hold. A value of 1 indicates perfect space
|
||||
// utilization. Smaller values indicate space wastage.
|
||||
// Returns 0 for empty trees.
|
||||
double fullness() const {
|
||||
if (empty()) return 0.0;
|
||||
return static_cast<double>(size()) / (nodes() * kNodeValues);
|
||||
}
|
||||
// The overhead of the btree structure in bytes per node. Computed as the
|
||||
// total number of bytes used by the btree minus the number of bytes used for
|
||||
// storing elements divided by the number of elements.
|
||||
// Returns 0 for empty trees.
|
||||
double overhead() const {
|
||||
if (empty()) {
|
||||
return 0.0;
|
||||
}
|
||||
if (empty()) return 0.0;
|
||||
return (bytes_used() - size() * sizeof(value_type)) /
|
||||
static_cast<double>(size());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue