https://github.com/gammazero/eytzinger
Eytzinger binary search
https://github.com/gammazero/eytzinger
binary-search eytzinger-binary-search
Last synced: 3 months ago
JSON representation
Eytzinger binary search
- Host: GitHub
- URL: https://github.com/gammazero/eytzinger
- Owner: gammazero
- License: mit
- Created: 2022-06-03T17:19:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-03T18:32:44.000Z (about 3 years ago)
- Last Synced: 2025-02-18T11:12:31.315Z (4 months ago)
- Topics: binary-search, eytzinger-binary-search
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eytzinger
[](https://pkg.go.dev/github.com/gammazero/eytzinger)
[](LICENSE)Eytzinger binary search, minimalistic implementation.
Package eytzinger implements Eytzinger Binary Search, using generics to operate on any [ordered](https://pkg.go.dev/golang.org/x/exp/constraints#Ordered) type.
## Installation
```
$ go get github.com/gammazero/eytzinger
```## Example
```go
a := make([]int, 100)
for i := 0; i < len(a); i++ {
a[i] = i
}// Sort slice into Eytzinger order.
eytzinger.Sort(a)// Find some numbers.
for _, find := range []int{13, 17, 19, 23, 29, 37, 73} {
index := eytzinger.Search(a, find)
fmt.Println(find, "is at index", index)
}
```