good morning!!!!

Skip to content
Snippets Groups Projects
Commit 9550db02 authored by Garet Halliday's avatar Garet Halliday
Browse files

remove unused code

parent e2844596
No related branches found
No related tags found
No related merge requests found
package chans
func TrySend[T any](ch chan<- T, value T) bool {
select {
case ch <- value:
return true
default:
return false
}
}
func TryRecv[T any](ch <-chan T) (T, bool) {
select {
case value, ok := <-ch:
return value, ok
default:
return *new(T), false
}
}
package dio
import (
"io"
"time"
)
type Reader interface {
SetReadDeadline(deadline time.Time) error
io.Reader
}
package dio
import (
"time"
)
type ReadWriter interface {
SetDeadline(deadline time.Time) error
Reader
Writer
}
package dio
import (
"io"
"time"
)
type Writer interface {
SetWriteDeadline(deadline time.Time) error
io.Writer
}
package maps
func Clear[K comparable, V any](m map[K]V) {
for k := range m {
delete(m, k)
}
}
package maps
func Clone[K comparable, V any](value map[K]V) map[K]V {
if value == nil {
return nil
}
m := make(map[K]V, len(value))
for k, v := range value {
m[k] = v
}
return m
}
package maths
func Clamp[T Ordered](x, min, max T) T {
return Min(Max(x, min), max)
}
package maths
func Max[T Ordered](a, b T) T {
if a > b {
return a
}
return b
}
package maths
func Min[T Ordered](a, b T) T {
if a < b {
return a
}
return b
}
package maths
type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
~float32 | ~float64
}
package queue
import "sync"
type LIFO[T any] struct {
items []T
signal sync.Cond
mu sync.Mutex
}
func (v *LIFO[T]) init() {
if v.signal.L == nil {
v.signal.L = &v.mu
}
}
func (v *LIFO[T]) Push(item T) {
v.mu.Lock()
defer v.mu.Unlock()
v.init()
v.items = append(v.items, item)
v.signal.Signal()
}
func (v *LIFO[T]) Pop() T {
v.mu.Lock()
defer v.mu.Unlock()
v.init()
for len(v.items) == 0 {
v.signal.Wait()
}
item := v.items[len(v.items)-1]
v.items = v.items[:len(v.items)-1]
return item
}
package slices
func CloneInto[T any](dst, src []T) []T {
dst = Resize(dst, len(src))
for i, v := range src {
dst[i] = v
}
return dst
}
package slices
func Equal[T comparable](a, b []T) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment