aboutsummaryrefslogtreecommitdiffstats
path: root/_test/meowpp_BinaryIndexTree.cpp
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-05-02 04:10:56 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-05-02 04:10:56 +0800
commit33d419e4d54d969798af80f05e05f0c447a99594 (patch)
treec78355a2d334e34df865aca865dbb4864a85820c /_test/meowpp_BinaryIndexTree.cpp
parentd2d7a49563a8f04bd07264a4a989d5656313d375 (diff)
downloadmeow-33d419e4d54d969798af80f05e05f0c447a99594.tar.gz
meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.zst
meow-33d419e4d54d969798af80f05e05f0c447a99594.zip
big change about dir structure
Diffstat (limited to '_test/meowpp_BinaryIndexTree.cpp')
-rw-r--r--_test/meowpp_BinaryIndexTree.cpp57
1 files changed, 0 insertions, 57 deletions
diff --git a/_test/meowpp_BinaryIndexTree.cpp b/_test/meowpp_BinaryIndexTree.cpp
deleted file mode 100644
index 0b81f10..0000000
--- a/_test/meowpp_BinaryIndexTree.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "meowpp/dsa/BinaryIndexTree.h"
-#include "meowpp/utility.h"
-
-#include "meowpp.h"
-
-#include <vector>
-
-static int N = 100000;
-
-static std::vector<int> array;
-
-inline int sum(int k){
- int x = 0;
- for(int i = 0; i <= k; i++){
- x += array[i];
- }
- return x;
-}
-
-static meow::BinaryIndexTree<int> bit;
-
-TEST(BinaryIndexTree, "Test with large data"){
- size_t tMe = 0, tBi = 0, t0;
- for(int z = 0; z < 10; z++){
- meow::messagePrintf(1, "test %d", z);
- bit.reset(N, 0);
- array.clear();
- array.resize(N, 0);
-
- int NN = rand() % 10000;
- for(int i = 0; i < NN; i++){
- int index = rand() % N;
- if(rand() & 1){
- int val = rand() % 1000;
- t0 = clock(); array[i] += val; tMe += clock() - t0;
- t0 = clock(); bit.update(i, val); tBi += clock() - t0;
- }else{
- if(sum(index) != bit.query(index)){
- meow::messagePrintf(-1, "range-sum query fail");
- return false;
- }
- }
- }
- int s = 0;
- for(int i = 0; i < N; i++){
- s += array[i];
- if(s != bit.query(i)){
- meow::messagePrintf(-1, "range-sum query fail");
- return false;
- }
- }
- meow::messagePrintf(-1, "ok %.3f/%.3f",
- tBi * 1.0 / CLOCKS_PER_SEC,
- tMe * 1.0 / CLOCKS_PER_SEC);
- }
- return true;
-};