diff --git a/tdutils/test/heap.cpp b/tdutils/test/heap.cpp index c4c039f3..b361b95d 100644 --- a/tdutils/test/heap.cpp +++ b/tdutils/test/heap.cpp @@ -16,23 +16,21 @@ REGISTER_TESTS(heap) -using namespace td; - TEST(Heap, sort_random_perm) { int n = 1000000; - std::vector v(n); + td::vector v(n); for (int i = 0; i < n; i++) { v[i] = i; } // random shuffle for (int i = 1; i < n; i++) { - std::swap(v[Random::fast(0, i)], v[i]); + std::swap(v[td::Random::fast(0, i)], v[i]); } - std::vector nodes(n); - KHeap kheap; + td::vector nodes(n); + td::KHeap kheap; for (int i = 0; i < n; i++) { kheap.insert(v[i], &nodes[i]); } @@ -53,7 +51,7 @@ class CheckedHeap { nodes[i].value = i; } } - static void xx(int key, const HeapNode *heap_node) { + static void xx(int key, const td::HeapNode *heap_node) { const Node *node = static_cast(heap_node); std::fprintf(stderr, "(%d;%d)", node->key, node->value); } @@ -68,9 +66,9 @@ class CheckedHeap { } int random_id() const { CHECK(!empty()); - return ids[Random::fast(0, static_cast(ids.size() - 1))]; + return ids[td::Random::fast(0, static_cast(ids.size() - 1))]; } - size_t size() const { + std::size_t size() const { return ids.size(); } bool empty() const { @@ -142,19 +140,19 @@ class CheckedHeap { } private: - struct Node : public HeapNode { + struct Node : public td::HeapNode { Node() = default; Node(int key, int value) : key(key), value(value) { } int key = 0; int value = 0; }; - vector ids; - vector rev_ids; - vector free_ids; - vector nodes; + td::vector ids; + td::vector rev_ids; + td::vector free_ids; + td::vector nodes; std::set> set_heap; - KHeap kheap; + td::KHeap kheap; }; TEST(Heap, random_events) { @@ -165,11 +163,11 @@ TEST(Heap, random_events) { heap.top_key(); } - int x = Random::fast(0, 4); + int x = td::Random::fast(0, 4); if (heap.empty() || (x < 2 && heap.size() < 1000)) { - heap.insert(Random::fast(0, 99)); + heap.insert(td::Random::fast(0, 99)); } else if (x < 3) { - heap.fix_key(Random::fast(0, 99), heap.random_id()); + heap.fix_key(td::Random::fast(0, 99), heap.random_id()); } else if (x < 4) { heap.erase(heap.random_id()); } else if (x < 5) {