[Issue 5451] Three ideas for RedBlackTree
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 13 16:08:31 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5451
--- Comment #1 from bearophile_hugs at eml.cc 2011-01-13 16:06:38 PST ---
Two more ideas:
4) If this code is meant as correct (the two Foos have the same x but different
y), they you may add this example to the std_container.html page.
import std.container: RedBlackTree;
struct Foo {
int x, y;
}
void main() {
auto t = RedBlackTree!(Foo, "a.x < b.x")(Foo(1,1));
assert(Foo(1,2) in t);
}
In practice this looks like a tree map instead of a tree set.
---------------------
5) Built-in AAs can't work with approximate items (like floating point numbers)
but a search tree is usable to create such set. So I suggest to add to the
std.collections module a free templated function approxInsert(), its arguments
are a tree, an item, and an approximate equality predicate.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list