You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,10 @@ and ensure goroutines quit so objects can be GC'd. Threadsafety is achieved
49
49
using only CAS operations making this queue quite fast. Benchmarks can be found
50
50
in that package.
51
51
52
+
#### Fibonacci Heap
53
+
54
+
A standard Fibonacci heap providing the usual operations. Can be useful in executing Dijkstra or Prim's algorithms in the theoretically minimal time. Also useful as a general-purpose priority queue. The special thing about Fibonacci heaps versus other heap variants is the cheap decrease-key operation. This heap has a constant complexity for find minimum, insert and merge of two heaps, an amortized constant complexity for decrease key and O(log(n)) complexity for a deletion or dequeue minimum. In practice the constant factors are large, so Fibonacci heaps could be slower than Pairing heaps, depending on usage. Benchmarks - in the project subfolder. The heap has not been designed for thread-safety.
55
+
52
56
#### Range Tree
53
57
54
58
Useful to determine if n-dimensional points fall within an n-dimensional range.
@@ -147,7 +151,7 @@ method which in turn calls into runtime.assertI2T. We need generics.
147
151
148
152
#### Immutable B Tree
149
153
A btree based on two principals, immutablability and concurrency.
150
-
Somewhat slow for single value lookups and puts, it is very fast for bulk operations.
154
+
Somewhat slow for single value lookups and puts, it is very fast for bulk operations.
151
155
A persister can be injected to make this index persistent.
Copy file name to clipboardExpand all lines: documentation.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The goal of the go-datastructures library is to port implementations of some common datastructures to Go or to improve on some existing datastructures. These datastructures are designed to be re-used for anyone that needs them throughout the community. (and hopefully improved upon).
4
4
5
-
Given the commonality and popularity of these datastructures in other languages, it is hoped that by open sourcing this library we an leverage a great deal of institutional knowledge to improve upon the Go-specific implementations.
5
+
Given the commonality and popularity of these datastructures in other languages, it is hoped that by open sourcing this library we leverage a great deal of institutional knowledge to improve upon the Go-specific implementations.
6
6
7
7
# Datastructures
8
8
@@ -16,7 +16,7 @@ The actual implementation is a top-down red-black binary search tree.
16
16
17
17
### Future
18
18
19
-
Implement a bottom-up version as well.
19
+
Implement a bottom-up version as well.
20
20
21
21
## Bit Array
22
22
@@ -46,7 +46,7 @@ When I get time, I'd like to implement a lockless ring buffer for further perfor
46
46
47
47
## Range Tree
48
48
49
-
The range tree is a way to store n-dimensional points of data in a manner that it permits logarithmic queries. These points are usually representing as points on a Cartesian graph represented by integers.
49
+
The range tree is a way to store n-dimensional points of data in a manner that permits logarithmic-complexity queries. These points are usually represented as points on a Cartesian graph represented by integers.
50
50
51
51
There are two implementations of a range tree in this package, one that is mutable and one that is immutable. The mutable version can be faster, but involves lock contention if the consumer needs to ensure threadsafety. The immutable version is a copy-on-write range tree that is optimized by only copying portions of the rangetree on write and is best written to in batches. Operations on the immutable version are slower, but it is safe to read and write from this version at the same time from different threads.
52
52
@@ -56,6 +56,14 @@ Although rangetrees are often represented as BBSTs as described above, the n-dim
56
56
57
57
Unite both implementations of the rangetree under the same interface. The implementations (especially the immutable one) could use some futher performance optimizations.
58
58
59
+
## Fibonacci Heap
60
+
61
+
The usual Fibonacci Heap with a floating-point priority key. Does a good job as a priority queue, especially for large n. Should be useful in writing an optimal solution for Dijkstra's and Prim's algorithms. (because of it's efficient decrease-key)
62
+
63
+
### Future
64
+
65
+
I'd like to add a value interface{} pointer that will be able to hold any user data attached to each node in the heap. Another thing would be writing a fast implementation of Dijkstra and Prim using this structure. And a third would be analysing thread-safety and coming up with a thread-safe variant.
66
+
59
67
## Set
60
68
61
69
Not much to say here. This is an unordered set back by a Go map. This particular version is threadsafe which does hinder performance a bit, although reads can happen simultaneously.
@@ -76,4 +84,4 @@ This package just wraps some common interfaces with a lock to make them threadsa
76
84
77
85
There is a PR into the datastructures repo that contains some pieces required for implementing a B+ tree. With a B+ tree and bitmap, the pieces are in place to write a native Go database. Going forward, I'd like to take these pieces, expand upon them, and implement a fast database in Go.
78
86
79
-
As always, any optimizations or bug fixes in any of this code would be greatly appreciated and encouraged :). These datastructures can and are the foundations of many programs and algorithms, even if they are abstracted away in different libraries which makes working with them a lot of fun and very informative.
87
+
As always, any optimizations or bug fixes in any of this code would be greatly appreciated and encouraged :). These datastructures can and are the foundations of many programs and algorithms, even if they are abstracted away in different libraries which makes working with them a lot of fun and very informative.
0 commit comments