dkondor / orbtree Goto Github PK
View Code? Open in Web Editor NEWGeneralized order-statistic tree implementation in C++
License: BSD 3-Clause "New" or "Revised" License
Generalized order-statistic tree implementation in C++
License: BSD 3-Clause "New" or "Revised" License
The example below demonstrates the problem:
struct count {
typedef float argument_type;
typedef unsigned int result_type;
unsigned int operator()(const float& p) const {
return 10;
}
};
int main() {
orbtree::simple_multiset<int, count> map;
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 0
// Adding this line fixes the tests below
//map.insert(1000);
map.insert(5);
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 0: should be 0 0 10
map.insert(5);
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); /// 0 0 0: should be 0 0 20
map.insert(5 + 2);
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 20: should be 0 0 20
printf("erase 2: %d\n", map.erase(5 + 2)); // 1
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 0: should be 0 0 20
map.insert(5 + -1);
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 10 0: should be 0 10 30
printf("erase -1: %d\n", map.erase(5 + -1)); // 1
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 0: should be 0 0 20
printf("erase 0: %d\n", map.erase(5)); // 2
printf("%d %d %d\n", map.get_sum(5 + -1), map.get_sum(5), map.get_sum(5 + 1)); // 0 0 0
}
Hi there
Thanks for making this implementation public.
Is it possible to instantiate a rankmultimap
with the double
-typed keys and values?
I've tried to do so with the following:
orbtree::rankmultimap<double, double, uint32_t> multimap;
but I get the following compiler error. I had thought I had correctly specified uint32_t
as the NVType
.
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree.h: In instantiation of 'struct orbtree:
:RankFunc<unsigned int, orbtree::KeyValue<double, double, orbtree::trivial_pair> >':
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree.h:594:40: required from 'struct orbtr
ee::NVFunc_Adapter_Simple<orbtree::RankFunc<unsigned int, orbtree::KeyValue<double, double, orbtree::tri
vial_pair> > >'
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree_base.h:44:11: required from 'class or
btree::NVFunc_wrapper<orbtree::NVFunc_Adapter_Simple<orbtree::RankFunc<unsigned int, orbtree::KeyValue<d
ouble, double, orbtree::trivial_pair> > > >'
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree_base.h:63:8: required from 'class orb
tree::orbtree_base<orbtree::NodeAllocatorPtr<orbtree::KeyValue<double, double, orbtree::trivial_pair>, u
nsigned int, true>, std::less<double>, orbtree::NVFunc_Adapter_Simple<orbtree::RankFunc<unsigned int, or
btree::KeyValue<double, double, orbtree::trivial_pair> > >, true>'
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree.h:80:8: required from 'class orbtree:
:orbtree<orbtree::NodeAllocatorPtr<orbtree::KeyValue<double, double, orbtree::trivial_pair>, unsigned in
t, true>, std::less<double>, orbtree::NVFunc_Adapter_Simple<orbtree::RankFunc<unsigned int, orbtree::Key
Value<double, double, orbtree::trivial_pair> > >, true, true>'
/home/tw395/rds/hpc-work/gps_cpp/PPEcdf/PPEcdf.cpp:77:53: required from here
/home/tw395/rds/hpc-work/gps_cpp/build/_deps/orbtree-src/orbtree.h:811:43: error: static assertion faile
d: rank variable must be integral!
811 | static_assert(std::is_integral<NVType>::value, "rank variable must be integral!\n");
| ^~~~~
make[2]: *** [PPEcdf/CMakeFiles/PPEcdf.dir/PPEcdf.cpp.o] Error 1
make[1]: *** [PPEcdf/CMakeFiles/PPEcdf.dir/all] Error 2
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.