This is a repo to implement some data structures in go's generic syntax. The go generic is actually under development and the draft design can be found here.
Since the design might be subject to change, this repo will be updated accordingly.
- Vector (a wrapper of go slice)
- LinkedList (go's container/list with generic supported)
- Stack (impl using both LinkedList and slice)
- Queue (impl using both LinkedList and slice)
- Deque (impl using both LinkedList and slice)
- Pair
- HashSet (a wrapper of
map[T]struct{}) - PriortyQueue
- OrderedMap (hash map with insertion order preserved, e.g. can be used as LRU-cache)
- AVLTree
My merged test script can be found in this go2go-playground.
Note that at this time, the go2go playground is the only platform that to run go-generic-style code...
- Red Black Tree
SortedMapandSortedSet(need benchmark of AVL Tree and Red Black Tree to decide which one to use)OrderedSet
Since the go2go-playground is the only way to write go-generic-style code, writing everything in the same package will be much easier to merge them into a single file and do testing there. The package structure is subject to change after the generic feature is released.
go fmt is not available at this time, as the generic syntax will be recognized as syntax error. The code format will be articulated after the geenric feature is released.