huandu / Skiplist
Licence: mit
Fast and easy-to-use skip list for Go.
Stars: ✭ 165
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Skiplist
Rustbreak
A simple, fast and easy to use self-contained single file storage for Rust
Stars: ✭ 315 (+90.91%)
Mutual labels: hashmap, database
Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (-2.42%)
Mutual labels: database
Sdb
Simple and fast string based key-value database with support for arrays and json
Stars: ✭ 159 (-3.64%)
Mutual labels: database
Vue Materialize Datatable
A fancy Materialize CSS datatable VueJS component.
Stars: ✭ 162 (-1.82%)
Mutual labels: database
Userbase
Create secure and private web apps using only static JavaScript, HTML, and CSS.
Stars: ✭ 2,029 (+1129.7%)
Mutual labels: database
Pg hashids
Short unique id generator for PostgreSQL, using hashids
Stars: ✭ 164 (-0.61%)
Mutual labels: database
Vscode
Connect to MongoDB and Atlas and directly from your VS Code environment, navigate your databases and collections, inspect your schema and use playgrounds to prototype queries and aggregations.
Stars: ✭ 161 (-2.42%)
Mutual labels: database
Dspp Keras
Protein order and disorder data for Keras, Tensor Flow and Edward frameworks with automated update cycle made for continuous learning applications.
Stars: ✭ 160 (-3.03%)
Mutual labels: database
Eicu Code
Code and website related to the eICU Collaborative Research Database
Stars: ✭ 159 (-3.64%)
Mutual labels: database
Vim Dadbod Completion
Database autocompletion powered by https://github.com/tpope/vim-dadbod
Stars: ✭ 163 (-1.21%)
Mutual labels: database
Db
A blazing fast ACID compliant NoSQL DataLake with support for storing 17 formats of data. Full SQL and DML capabilities along with Java stored procedures for advanced data processing.
Stars: ✭ 159 (-3.64%)
Mutual labels: database
Webtau
Webtau (short for web test automation) is a testing API, command line tool and a framework to write unit, integration and end-to-end tests. Test across REST-API, Graph QL, Browser, Database, CLI and Business Logic with consistent set of matchers and concepts. REPL mode speeds-up tests development. Rich reporting cuts down investigation time.
Stars: ✭ 156 (-5.45%)
Mutual labels: database
Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (-2.42%)
Mutual labels: database
Node Oracledb
Oracle Database driver for Node.js maintained by Oracle Corp.
Stars: ✭ 2,018 (+1123.03%)
Mutual labels: database
Skip List in Golang
Skip list is an ordered map. See wikipedia page skip list to learn algorithm details about this data structure.
Highlights in this implementation:
- Built-in types can be used as key with predefined key types. See Int and related constants as a sample.
- Support custom comparable function so that any type can be used as key.
- Key sort order can be changed quite easily. See Reverse and LessThanFunc.
- Rand source and max level can be changed per list. It can be useful in performance critical scenarios.
Install
Install this package through go get
.
go get github.com/huandu/skiplist
Basic Usage
Here is a quick sample.
package main
import (
"fmt"
"github.com/huandu/skiplist"
)
func main() {
// Create a skip list with int key.
list := skiplist.New(skiplist.Int)
// Add some values. Value can be anything.
list.Set(12, "hello world")
list.Set(34, 56)
list.Set(78, 90.12)
// Get element by index.
elem := list.Get(34) // Value is stored in elem.Value.
fmt.Println(elem.Value) // Output: 56
next := elem.Next() // Get next element.
prev := next.Prev() // Get previous element.
fmt.Println(next.Value, prev.Value) // Output: 90.12 56
// Or, directly get value just like a map
val, ok := list.GetValue(34)
fmt.Println(val, ok) // Output: 56 true
// Remove an element for key.
list.Remove(34)
}
GreaterThanFunc
and LessThanFunc
Using Define your own GreaterThanFunc
or LessThanFunc
to use any custom type as the key in a skip list.
The signature of GreaterThanFunc
are LessThanFunc
are the same.
The only difference between them is that LessThanFunc
reverses result returned by custom func
to make the list ordered by key in a reversed order.
type T struct {
Rad float64
}
list := New(GreaterThanFunc(func(k1, k2 interface{}) int {
s1 := math.Sin(k1.(T).Rad)
s2 := math.Sin(k2.(T).Rad)
if s1 > s2 {
return 1
} else if s1 < s2 {
return -1
}
return 0
}))
list.Set(T{math.Pi / 8}, "sin(π/8)")
list.Set(T{math.Pi / 2}, "sin(π/2)")
list.Set(T{math.Pi}, "sin(π)")
fmt.Println(list.Front().Value) // Output: sin(π)
fmt.Println(list.Back().Value) // Output: sin(π/2)
License
This library is licensed under MIT license. See LICENSE for details.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].