first, next, prev, last in gb_trees

Ulf Wiger <>
Wed Mar 16 18:13:10 CET 2011

When I use ordered_set ets over gb_trees it has more than once been due to the fact that you can do wonderful stuff with first, next, prev and last - and gb_trees doesn't have them.

I've made a stab at implementing these functions for the gb_trees data structure, together with a quickcheck spec to verify that they work as expected (you can use eqc mini to run the tests). I think they are reasonably efficient, but perhaps someone can think of a way to optimize them? Have at it, and pls use the spec to verify that you didn't break them* (recalling that an incorrect program can be made arbitrarily fast)

* e.g. eqc:quickcheck(gb1:prop_first())

Ulf W (hoping the list server won't chop the 150-line attachment)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gb1.erl
Type: application/octet-stream
Size: 2812 bytes
Desc: not available
URL: <>
-------------- next part --------------

Ulf Wiger, CTO, Erlang Solutions, Ltd.

More information about the erlang-questions mailing list