github.com/perdata/treap (go): Package treap implements a persistent treap (tree/heap combination).  https://en.wikipedia.org/wiki/Treap  A treap is a binary search tree for storing ordered distinct values (duplicates not allowed). In addition, each node actually a random priority field which is stored in heap order (i.e. all children have lower priority than the parent)  This provides the basis for efficient immutable ordered Set operations.  See the ordered map example for how this can be used as an ordered map  Much of this is based on "Fast Set Operations Using Treaps" by Guy E Blelloch and Margaret Reid-Miller: https://www.cs.cmu.edu/~scandal/papers/treaps-spaa98.pdf  The most interesting benchmark is the performance of insert where a single random key is inserted into a 5k sized map.  As the example shows, the treap structure does well here as opposed to a regular persistent map (which involves full copying).  This benchmark does not take into account the fact that the regular maps are not sorted unlike treaps.  The intersection benchmark compares the case where two 10k sets with 5k in common being interesected. The regular persistent array is about 30% faster but this is still respectable showing for treaps.
Keywords: golang|heap|immutable|map|persistent|set|treap|tree