Data structure and algorithm library for go, designed to provide functions similar to C++ STL
Data structure and algorithm library for go, designed to provide functions similar to C++ STL
English | 简体中文
GoSTL is a data structure and algorithm library for go, designed to provide functions similar to C++ STL, but more powerful. Combined with the characteristics of go language, most of the data structures have realized goroutine-safe. When creating objects, you can specify whether to turn it on or not through configuration parameters.
The slice in this library is a wrapper of go native slice.
package main
import (
"fmt"
"github.com/liyue201/gostl/algorithm/sort"
"github.com/liyue201/gostl/ds/slice"
"github.com/liyue201/gostl/utils/comparator"
)
func main() {
a := make([]int, 0)
a = append(a, 2)
a = append(a, 1)
a = append(a, 3)
fmt.Printf("%v\n", a)
wa := slice.NewSliceWrapper(a)
// sort in ascending
sort.Sort[int](wa.Begin(), wa.End(), comparator.IntComparator)
fmt.Printf("%v\n", a)
// sort in descending
sort.Sort[int](wa.Begin(), wa.End(), comparator.Reverse(comparator.IntComparator))
fmt.Printf("%v\n", a)
}
Array is a data structure with fixed length once it is created, which supports random access and iterator access.
…No open issues yet, or sync has not completed.