tinloaf / ygg Goto Github PK
View Code? Open in Web Editor NEWAn intrusive C++17 implementation of a Red-Black-Tree, a Weight Balanced Tree, a Dynamic Segment Tree and much more!
Home Page: https://tinloaf.github.io/ygg/
License: MIT License
An intrusive C++17 implementation of a Red-Black-Tree, a Weight Balanced Tree, a Dynamic Segment Tree and much more!
Home Page: https://tinloaf.github.io/ygg/
License: MIT License
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]
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.
const_cast<decltype(this)>(this)->find(query)
just leads to infinite recursion, should use MyClass *
.
Thanks for developing this repo, and it helps me a lot!
I'd like to create an intervalTree, and use query() method through multi-threading, can this be done?
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 value
s 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!
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.
Pointer addresses in hexadecimal appear to get rejected by dot.
An easy workaround is to quote them.
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.