mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-517] Remove copyright notices from all doc.go. * [NOD-517] Updated the root doc.go. * [NOD-517] Remove all cov_report.sh and test_coverage.txt. * [NOD-517] Make all doc.go use the same style of comment. * [NOD-517] Update dagconfig doc.go. * [NOD-517] Update blockdag doc.go. * [NOD-517] Update doc.go in connmgr. * [NOD-517] Update doc.go in fullblocktests. * [NOD-517] Update doc.go in database. * [NOD-517] Update doc.go in ecc. * [NOD-517] Update doc.go in rpctest. * [NOD-517] Removed superfluous license in logs. * [NOD-517] Update doc.go in mempool. * [NOD-517] Updated doc.go in peer. * [NOD-517] Update doc.go in rpcclient. * [NOD-517] Update doc.go in txscript. * [NOD-517] Update doc.go in util. * [NOD-517] Update doc.go in base58. * [NOD-517] Update doc.go in bech32. * [NOD-517] Update doc.go in txsort. * [NOD-517] Update doc.go in wire. * [NOD-517] Fix indentation. * [NOD-517] Add a copyright notice to the main doc.go. * [NOD-517] Add Conformal to the license notices. * [NOD-517] Remove superfluous language from a doc. * [NOD-517] Fix bad example.
24 lines
1.4 KiB
Go
24 lines
1.4 KiB
Go
/*
|
|
Package treap implements a treap data structure that is used to hold ordered
|
|
key/value pairs using a combination of binary search tree and heap semantics.
|
|
It is a self-organizing and randomized data structure that doesn't require
|
|
complex operations to to maintain balance. Search, insert, and delete
|
|
operations are all O(log n). Both mutable and immutable variants are provided.
|
|
|
|
The mutable variant is typically faster since it is able to simply update the
|
|
treap when modifications are made. However, a mutable treap is not safe for
|
|
concurrent access without careful use of locking by the caller and care must be
|
|
taken when iterating since it can change out from under the iterator.
|
|
|
|
The immutable variant works by creating a new version of the treap for all
|
|
mutations by replacing modified nodes with new nodes that have updated values
|
|
while sharing all unmodified nodes with the previous version. This is extremely
|
|
useful in concurrent applications since the caller only has to atomically
|
|
replace the treap pointer with the newly returned version after performing any
|
|
mutations. All readers can simply use their existing pointer as a snapshot
|
|
since the treap it points to is immutable. This effectively provides O(1)
|
|
snapshot capability with efficient memory usage characteristics since the old
|
|
nodes only remain allocated until there are no longer any references to them.
|
|
*/
|
|
package treap
|