dcrd/database/internal/treap
Dave Collins ad02d8f300
multi: Go 1.19 doc comment formatting.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.

The primary motivating factors for this are:

- Builds check that files are formatted per gofmt and that will no
  longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
  documentation only formatting changes do not clutter up diffs that
  actually change code

For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.

For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not.  Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
2022-07-30 04:08:58 -05:00
..
common_test.go multi: remove unused funcs and vars 2017-12-07 21:46:25 -06:00
common.go multi: Correct typos. 2019-08-22 10:20:03 -05:00
doc.go multi: Correct typos. 2019-08-16 17:37:58 -05:00
immutable_test.go multi: Correct typos. 2019-08-22 10:20:03 -05:00
immutable.go multi: Correct typos. 2019-08-16 17:37:58 -05:00
mutable_test.go multi: Correct typos. 2019-08-22 10:20:03 -05:00
mutable.go multi: Correct typos. 2019-08-16 17:37:58 -05:00
README.md multi: replace godoc.org with pkg.go.dev 2020-02-18 19:35:19 -06:00
treapiter_test.go database: Replace with new version. 2016-08-23 17:40:38 -04:00
treapiter.go multi: Go 1.19 doc comment formatting. 2022-07-30 04:08:58 -05:00

treap

Build Status ISC License Doc

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 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 is licensed under the copyfree ISC license.

Usage

This package is only used internally in the database code and as such is not available for use outside of it.

License

Package treap is licensed under the copyfree ISC License.