Giter Club home page Giter Club logo

ygg's Issues

Passing a {0, 0} in the intervaltree example

Passing a {0, 0} in the intervaltree example crashes with a seg fault. I'm trying to ask the interval tree to return Nodes that contain the point 0.

Here's the code I'm using. I hope I'm not doing anything stupid.

// intv_test.mm

#include <tuple>
#include <string>
#include <iostream>
#include <ygg/intervaltree.hpp>

using Interval = std::pair<int, int>;

template<class Node>
class NodeTraits : public ygg::ITreeNodeTraits<Node> {
public:
  using key_type = int;
  static int get_lower(const Node& node) {
    return node.lower;
  }
  static int get_upper(const Node& node) {
    return node.upper;
  }
  static int get_lower(const Interval& i) {
    return std::get<0>(i);
  }
  static int get_upper(const Interval& i) {
    return std::get<1>(i);
  }
};

class Node : public ygg::ITreeNodeBase<Node, NodeTraits<Node>> {
public:
  int upper;
  int lower;
  std::string value;
};

using Tree = ygg::IntervalTree<Node, NodeTraits<Node>>;

int main(int argc, const char **argv) {
  Tree t;
  Node nodes[5];
  for (std::uint64_t i = 0; i < 5; i++) {
    nodes[i].lower = i;
    nodes[i].upper = i + 5;
    nodes[i].value = std::string("The interval is [") + std::to_string(i) + std::string(", ") + std::to_string((i+5)) + std::string("]");
    t.insert(nodes[i]);
  }
  Interval queryRange {0, 0};
  for (const auto& node : t.query(queryRange)) {
    std::cout << node.value << std::endl;
  }
  return 0;
}

And, for the sake of completeness, the output is:

$ ./intv_test
The interval is [0, 5]
Segmentation fault: 11

Also, passing {1, 1} gives the expected output:

$ ./intv_test
The interval is [0, 5]
The interval is [1, 6]

It is hard to understand, which PAPI is used in the project

Installing the newest PAPI (7.0.1) breaks build. Error messages:

[build] <ygg-dir>/ygg/benchmark/common.hpp: In member function «void PapiMeasurements::initialize()»:
[build] <ygg-dir>/ygg/benchmark/common.hpp:187:44: error: «PAPI_num_counters» was not declared in this scope; did you mean «PAPI_num_hwctrs»?
[build]   187 |                         int num_counters = PAPI_num_counters();
[build]       |                                            ^~~~~~~~~~~~~~~~~
[build]       |                                            PAPI_num_hwctrs
[build] <ygg-dir>/ygg/benchmark/common.hpp: In member function «void PapiMeasurements::start()»:
[build] <ygg-dir>/ygg/benchmark/common.hpp:240:17: error: «PAPI_start_counters» was not declared in this scope
[build]   240 |                 PAPI_start_counters(this->selected_events.data(),
[build]       |                 ^~~~~~~~~~~~~~~~~~~
[build] <ygg-dir>/ygg/benchmark/common.hpp: In member function «void PapiMeasurements::stop()»:
[build] <ygg-dir>/ygg/benchmark/common.hpp:250:17: error: «PAPI_stop_counters» was not declared in this scope
[build]   250 |                 PAPI_stop_counters(this->event_counts.data(),
[build]       |                 ^~~~~~~~~~~~~~~~~~

These changes are caused by changes in PAPI. There is no information in README files, which exact PAPI version is used. The user has to guess the version.

Question: Tree with NodeUpdater

Hi!

Can I somehow make work *Tree with a sort of "Combiner" (like from DynamicIntervalTree)?
I would like to have a balanced binary tree with a custom metadata inside and a hook from a tree implementation to recalculate metadata, based on children metadata.
For example, if I want to have (key -> value) mapping, sorted by key. And in each node as a metadata: sum of values in a subtree, number of elements in that subtree available.
Is this somehow possible with that library? (I'm looking for some solution to replace gnu::pb_ds in my project)

Thank you for answer!

erase on iterators

Trees should provide erase on iterators, returning the next iterator, for consistency with other containers.

The alternative is to use remove, but that's not compatible with algorithms.

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.