1#include <gtest/gtest.h>
28 EXPECT_EQ(treap.
size(), 3u);
39 EXPECT_EQ(treap[
"one"], 1);
40 EXPECT_EQ(treap[
"two"], 2);
41 EXPECT_EQ(treap[
"three"], 3);
49 EXPECT_EQ(treap[10], 100);
52 EXPECT_EQ(treap[10], 200);
61 EXPECT_TRUE(treap.
has(5));
62 EXPECT_FALSE(treap.
has(10));
73 EXPECT_TRUE(treap.
remove(2));
74 EXPECT_FALSE(treap.
has(2));
75 EXPECT_TRUE(treap.
has(1));
76 EXPECT_TRUE(treap.
has(3));
86 EXPECT_EQ(treap[
"apple"], 1);
87 EXPECT_EQ(treap[
"banana"], 2);
98 EXPECT_EQ(treap[-5], 50);
99 EXPECT_EQ(treap[0], 0);
106 for (
int i = 0; i < 100; ++i)
109 EXPECT_EQ(treap.
size(), 100u);
111 for (
int i = 0; i < 100; i += 10)
112 EXPECT_EQ(treap[i], i * 2);
119 for (
int i = 0; i < 50; ++i)
122 EXPECT_EQ(treap.
size(), 50u);
124 for (
int i = 0; i < 50; i += 2)
128 EXPECT_EQ(treap.
size(), 25u);
130 for (
int i = 1; i < 50; i += 2)
131 EXPECT_TRUE(treap.
has(i));
142 EXPECT_EQ(treap2.
size(), 2u);
143 EXPECT_EQ(treap2[1],
"one");
144 EXPECT_EQ(treap2[2],
"two");
Data remove(const Key &key)
Deletes the pair key,data
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
bool has(const Key &key) const noexcept(nothrow_search)
Return whether key is in the map.
const size_t & size() const
Returns the cardinality of the set.
bool is_empty() const
returns true if the set is empty
TEST_F(DynTreapTest, DefaultConstructor)
Main namespace for Aleph-w library functions.
Dynamic mapping implemented with treap trees.