[erlang-questions] strange behaviour of gb_trees

Ulf Wiger ulf.wiger@REDACTED
Sat May 28 20:17:13 CEST 2011


On 28 May 2011, at 00:39, Nico Meyer wrote:

> Try instead
> 1> T = gb_trees:from_orddict( lists:sort(P) ).

To maintain the abstraction, it should be

1> T = gb_trees:from_orddict( orddict:from_list(P) ).

Note that orddicts are not just sorted lists - they are sorted {Key, Value} lists where each key occurs at most once.

Note also:

2> orddict:from_list([{a,1},{a,2}]).
[{a,2}]
3> lists:ukeysort(1,[{a,1},{a,2}]). 
[{a,1}]

Again, stick to the abstraction wherever possible, in order to avoid surprises.

BR,
Ulf W

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com






More information about the erlang-questions mailing list