Update treap.cpp

Treap is a binary search tree that balanced anticipatory using a random number.

Key and Value is added as well as binary search tree common to each node, the order is attached by Key as well as binary search tree. Each node has a Priority On top of that, his has a large Priority than their own children. You go through the rotation of the tree to keep it. I can be implemented in very simple this.

Be balanced anticipatory to be assigned randomly Priority is shown. Since it is not balanced exactly speed to pull in the vertex inferior to red-black tree and AVL tree, the rotation operation is fast, it may be faster than they add or remove vertices.

Amount of calculation

insert, erase, find: O (log n)
eval: amortized O (1)
However expexted

How to use

Eval, such as cache is not required if the mere binary search tree application, I would be 50 lines or so.

typedef xxx Key;
Type from Digi-Key. Assumes total order.
typedef xxx Value;
Type the Value.
typedef xxx Result;
result type of eval.
Treap * find (Treap *, Key);
I return a pointer to the element with the key.
Treap * insert (Treap *, Key, Value);
Insert (key, value) a.
Treap * erase (Treap *, Key);
Delete an element with a key.
Result eval (Treap *);
I assess the value. And returns it if it is cached.