Coder Social home page Coder Social logo

orbtree's People

Contributors

dkondor avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

orbtree's Issues

rankmultimap with doubles as keys and values?

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

simple_multiset ignores the last element?

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.