Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(condition Bool, args ...any)
- func AssertEq[T Eq[T]](lhs T, rhs T, args ...any)
- func AssertNe[T Eq[T]](lhs T, rhs T, args ...any)
- func If[T any](condition Bool, expression func() T) ifElseContext[T]
- func Panic(message String, args ...any)
- func Print(format String, params ...any)
- func Println(format String, params ...any)
- func Sleep(dur Duration)
- func Todo(messages ...String)
- func Unimplemented(messages ...String)
- func Unreachable(messages ...String)
- type Add
- type AddAssign
- type Any
- type AsRef
- type BTreeMap
- func (self BTreeMap[K, V]) AsRef() *BTreeMap[K, V]
- func (self *BTreeMap[K, V]) Clear()
- func (self *BTreeMap[K, V]) ContainsKey(key K) Bool
- func (self BTreeMap[K, V]) Debug() String
- func (self BTreeMap[K, V]) Display() String
- func (self BTreeMap[K, V]) Eq(other *BTreeMap[K, V]) bool
- func (self *BTreeMap[K, V]) Get(key K) Option[V]
- func (self *BTreeMap[K, V]) Insert(key K, value V) Option[V]
- func (self BTreeMap[K, V]) IntoIter() Iterator[Pair[K, V]]
- func (self *BTreeMap[K, V]) IsEmpty() Bool
- func (self BTreeMap[K, V]) Keys() Iterator[K]
- func (self *BTreeMap[K, V]) Len() USize
- func (self *BTreeMap[K, V]) Remove(key K) Option[V]
- func (self BTreeMap[K, V]) Values() Iterator[V]
- type BTreeMapIter
- func (self BTreeMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]
- func (self BTreeMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]
- func (self *BTreeMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]
- func (self *BTreeMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]
- func (self *BTreeMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]
- func (self *BTreeMapIter[K, V]) Next() Option[Pair[K, V]]
- func (self BTreeMapIter[K, V]) Rev() Iterator[Pair[K, V]]
- type BTreeMapKeys
- func (self BTreeMapKeys[K]) CollectToLinkedList() LinkedList[K]
- func (self BTreeMapKeys[K]) CollectToVec() Vec[K]
- func (self *BTreeMapKeys[K]) Filter(f func(K) Bool) Iterator[K]
- func (self *BTreeMapKeys[K]) Fold(init K, f func(K, K) K) K
- func (self *BTreeMapKeys[K]) Map(f func(K) K) Iterator[K]
- func (self *BTreeMapKeys[K]) Next() Option[K]
- func (self BTreeMapKeys[K]) Rev() Iterator[K]
- type BTreeMapValues
- func (self BTreeMapValues[V]) CollectToLinkedList() LinkedList[V]
- func (self BTreeMapValues[V]) CollectToVec() Vec[V]
- func (self *BTreeMapValues[V]) Filter(f func(V) Bool) Iterator[V]
- func (self *BTreeMapValues[V]) Fold(init V, f func(V, V) V) V
- func (self *BTreeMapValues[V]) Map(f func(V) V) Iterator[V]
- func (self *BTreeMapValues[V]) Next() Option[V]
- func (self BTreeMapValues[V]) Rev() Iterator[V]
- type BTreeNode
- type BTreeSet
- func (self BTreeSet[K]) AsRef() *BTreeSet[K]
- func (self *BTreeSet[K]) Clear()
- func (self BTreeSet[K]) Clone() BTreeSet[K]
- func (self *BTreeSet[K]) Contains(key K) Bool
- func (self BTreeSet[K]) Debug() String
- func (self BTreeSet[K]) Display() String
- func (self BTreeSet[K]) Eq(other BTreeSet[K]) Bool
- func (self *BTreeSet[K]) Insert(key K) Bool
- func (self BTreeSet[K]) Intersection(other BTreeSet[K]) BTreeSet[K]
- func (self *BTreeSet[K]) IntoIter() Iterator[K]
- func (self BTreeSet[K]) IsDisjoint(other BTreeSet[K]) Bool
- func (self BTreeSet[K]) IsEmpty() Bool
- func (self BTreeSet[K]) IsSubset(other BTreeSet[K]) Bool
- func (self BTreeSet[K]) IsSuperset(other BTreeSet[K]) Bool
- func (self BTreeSet[K]) Len() USize
- func (self *BTreeSet[K]) Remove(key K) Bool
- func (self BTreeSet[K]) SymmetricDifference(other BTreeSet[K]) BTreeSet[K]
- func (self BTreeSet[K]) Union(other BTreeSet[K]) BTreeSet[K]
- type BTreeSetIter
- func (self BTreeSetIter[K]) CollectToLinkedList() LinkedList[K]
- func (self BTreeSetIter[K]) CollectToVec() Vec[K]
- func (self BTreeSetIter[K]) Filter(f func(K) Bool) Iterator[K]
- func (self BTreeSetIter[K]) Fold(init K, f func(K, K) K) K
- func (self BTreeSetIter[K]) Map(f func(K) K) Iterator[K]
- func (self *BTreeSetIter[K]) Next() Option[K]
- func (self BTreeSetIter[K]) Rev() Iterator[K]
- type BinaryHeap
- func (self *BinaryHeap[T]) Append(other *BinaryHeap[T])
- func (self *BinaryHeap[T]) AsSlice() []T
- func (self BinaryHeap[T]) Capacity() USize
- func (self *BinaryHeap[T]) Clear()
- func (self *BinaryHeap[T]) IntoSortedVec() Vec[T]
- func (self *BinaryHeap[T]) IntoVec() Vec[T]
- func (self BinaryHeap[T]) IsEmpty() Bool
- func (self BinaryHeap[T]) Len() USize
- func (self *BinaryHeap[T]) Pop() Option[T]
- func (self *BinaryHeap[T]) Push(item T)
- func (self *BinaryHeap[T]) Reserve(capacity USize)
- type Bool
- type Byte
- func (self Byte) Add(rhs Byte) Byte
- func (self *Byte) AddAssign(rhs Byte)
- func (self Byte) AsRef() *Byte
- func (self Byte) Clone() Byte
- func (self Byte) Cmp(rhs Byte) Ordering
- func (self Byte) Debug() String
- func (self Byte) Display() String
- func (self Byte) Div(rhs Byte) Byte
- func (self *Byte) DivAssign(rhs Byte)
- func (self Byte) Eq(rhs Byte) Bool
- func (self Byte) Mul(rhs Byte) Byte
- func (self *Byte) MulAssign(rhs Byte)
- func (self Byte) Sub(rhs Byte) Byte
- func (self *Byte) SubAssign(rhs Byte)
- func (self Byte) ToString() String
- type Char
- func (self Char) Add(rhs Char) Char
- func (self *Char) AddAssign(rhs Char)
- func (self Char) AsRef() *Char
- func (self Char) Clone() Char
- func (self Char) Cmp(rhs Char) Ordering
- func (self Char) Debug() String
- func (self Char) Display() String
- func (self Char) Div(rhs Char) Char
- func (self *Char) DivAssign(rhs Char)
- func (self Char) Eq(rhs Char) Bool
- func (self Char) Mul(rhs Char) Char
- func (self *Char) MulAssign(rhs Char)
- func (self Char) Sub(rhs Char) Char
- func (self *Char) SubAssign(rhs Char)
- func (self Char) ToString() String
- type Clone
- type Complex128
- func (self Complex128) Add(rhs Complex128) Complex128
- func (self *Complex128) AddAssign(rhs Complex128)
- func (self Complex128) AsRef() *Complex128
- func (self Complex128) Clone() Complex128
- func (self Complex128) Debug() String
- func (self Complex128) Display() String
- func (self Complex128) Div(rhs Complex128) Complex128
- func (self *Complex128) DivAssign(rhs Complex128)
- func (self Complex128) Mul(rhs Complex128) Complex128
- func (self *Complex128) MulAssign(rhs Complex128)
- func (self Complex128) Sub(rhs Complex128) Complex128
- func (self *Complex128) SubAssign(rhs Complex128)
- func (self Complex128) ToString() String
- type Complex64
- func (self Complex64) Add(rhs Complex64) Complex64
- func (self *Complex64) AddAssign(rhs Complex64)
- func (self Complex64) AsRef() *Complex64
- func (self Complex64) Clone() Complex64
- func (self Complex64) Debug() String
- func (self Complex64) Display() String
- func (self Complex64) Div(rhs Complex64) Complex64
- func (self *Complex64) DivAssign(rhs Complex64)
- func (self Complex64) Mul(rhs Complex64) Complex64
- func (self *Complex64) MulAssign(rhs Complex64)
- func (self Complex64) Sub(rhs Complex64) Complex64
- func (self *Complex64) SubAssign(rhs Complex64)
- func (self Complex64) ToString() String
- type Debug
- type Default
- type DirEntry
- type Display
- type Div
- type DivAssign
- type Duration
- type Eq
- type Error
- type F32
- func (self F32) Abs() F32
- func (self F32) Add(rhs F32) F32
- func (self *F32) AddAssign(rhs F32)
- func (self F32) AsRef() *F32
- func (self F32) Ceil() F32
- func (self F32) Clone() F32
- func (self F32) Cmp(rhs F32) Ordering
- func (self F32) Debug() String
- func (self F32) Display() String
- func (self F32) Div(rhs F32) F32
- func (self *F32) DivAssign(rhs F32)
- func (self F32) Eq(rhs F32) Bool
- func (self F32) Exp() F32
- func (self F32) Exp2() F32
- func (self F32) Floor() F32
- func (self F32) Frac() F32
- func (self F32) Ln() F32
- func (self F32) Log(base F32) F32
- func (self F32) Log10() F32
- func (self F32) Log2() F32
- func (self F32) Mul(rhs F32) F32
- func (self *F32) MulAssign(rhs F32)
- func (self F32) Powf(n F32) F32
- func (self F32) Powi(n int) F32
- func (self F32) Round() F32
- func (self F32) Sqrt() F32
- func (self F32) Sub(rhs F32) F32
- func (self *F32) SubAssign(rhs F32)
- func (self F32) ToString() String
- func (self F32) Trunc() F32
- type F64
- func (self F64) Abs() F64
- func (self F64) Add(rhs F64) F64
- func (self *F64) AddAssign(rhs F64)
- func (self F64) AsRef() *F64
- func (self F64) Ceil() F64
- func (self F64) Clone() F64
- func (self F64) Cmp(rhs F64) Ordering
- func (self F64) Debug() String
- func (self F64) Display() String
- func (self F64) Div(rhs F64) F64
- func (self *F64) DivAssign(rhs F64)
- func (self F64) Eq(rhs F64) Bool
- func (self F64) Exp() F64
- func (self F64) Exp2() F64
- func (self F64) Floor() F64
- func (self F64) Frac() F64
- func (self F64) Ln() F64
- func (self F64) Log(base F64) F64
- func (self F64) Log10() F64
- func (self F64) Log2() F64
- func (self F64) Mul(rhs F64) F64
- func (self *F64) MulAssign(rhs F64)
- func (self F64) Powf(n F64) F64
- func (self F64) Powi(n int) F64
- func (self F64) Round() F64
- func (self F64) Sqrt() F64
- func (self F64) Sub(rhs F64) F64
- func (self *F64) SubAssign(rhs F64)
- func (self F64) ToString() String
- func (self F64) Trunc() F64
- type FileType
- type Future
- type HashMap
- func (self HashMap[K, V]) AsMap() map[K]V
- func (self HashMap[K, V]) AsRef() *HashMap[K, V]
- func (self *HashMap[K, V]) Clear()
- func (self HashMap[K, V]) Clone() HashMap[K, V]
- func (self HashMap[K, V]) ContainsKey(key K) Bool
- func (self HashMap[K, V]) Debug() String
- func (self HashMap[K, V]) Display() String
- func (self HashMap[K, V]) Eq(rhs HashMap[K, V]) Bool
- func (self HashMap[K, V]) Get(key K) Option[V]
- func (self *HashMap[K, V]) Insert(key K, value V) Option[V]
- func (self HashMap[K, V]) IntoIter() Iterator[Pair[K, V]]
- func (self HashMap[K, V]) IsEmpty() Bool
- func (self HashMap[K, V]) Keys() Iterator[K]
- func (self HashMap[K, V]) Len() USize
- func (self *HashMap[K, V]) Remove(key K) Option[V]
- func (self HashMap[K, V]) Values() Iterator[V]
- type HashMapIter
- func (self HashMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]
- func (self HashMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]
- func (self HashMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]
- func (self HashMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]
- func (self HashMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]
- func (self *HashMapIter[K, V]) Next() Option[Pair[K, V]]
- func (self HashMapIter[K, V]) Rev() Iterator[Pair[K, V]]
- type HashMapKeys
- func (self HashMapKeys[K]) CollectToLinkedList() LinkedList[K]
- func (self HashMapKeys[K]) CollectToVec() Vec[K]
- func (self HashMapKeys[K]) Filter(f func(K) Bool) Iterator[K]
- func (self HashMapKeys[K]) Fold(init K, f func(K, K) K) K
- func (self HashMapKeys[K]) Map(f func(K) K) Iterator[K]
- func (self *HashMapKeys[K]) Next() Option[K]
- func (self HashMapKeys[K]) Rev() Iterator[K]
- type HashMapValues
- func (self HashMapValues[V]) CollectToLinkedList() LinkedList[V]
- func (self HashMapValues[V]) CollectToVec() Vec[V]
- func (self HashMapValues[V]) Filter(f func(V) Bool) Iterator[V]
- func (self HashMapValues[V]) Fold(init V, f func(V, V) V) V
- func (self HashMapValues[V]) Map(f func(V) V) Iterator[V]
- func (self *HashMapValues[V]) Next() Option[V]
- func (self HashMapValues[V]) Rev() Iterator[V]
- type HashSet
- func (self HashSet[K]) AsRef() *HashSet[K]
- func (self HashSet[K]) AsSlice() []K
- func (self *HashSet[K]) Clear()
- func (self HashSet[K]) Clone() HashSet[K]
- func (self HashSet[K]) Contains(value K) Bool
- func (self HashSet[K]) Debug() String
- func (self HashSet[K]) Display() String
- func (self HashSet[K]) Eq(rhs HashSet[K]) Bool
- func (self HashSet[K]) Get(value K) Option[K]
- func (self *HashSet[K]) Insert(value K) Bool
- func (self HashSet[K]) Intersection(other HashSet[K]) HashSet[K]
- func (self HashSet[K]) IntoIter() Iterator[K]
- func (self HashSet[K]) IsDisjoint(other HashSet[K]) Bool
- func (self HashSet[K]) IsEmpty() Bool
- func (self HashSet[K]) IsSubset(other HashSet[K]) Bool
- func (self HashSet[K]) IsSuperset(other HashSet[K]) Bool
- func (self HashSet[K]) Len() USize
- func (self *HashSet[K]) Remove(value K) Bool
- func (self HashSet[K]) SymmetricDifference(other HashSet[K]) HashSet[K]
- func (self HashSet[K]) Union(other HashSet[K]) HashSet[K]
- type HashSetIter
- func (self HashSetIter[K]) CollectToLinkedList() LinkedList[K]
- func (self HashSetIter[K]) CollectToVec() Vec[K]
- func (self HashSetIter[K]) Filter(f func(K) Bool) Iterator[K]
- func (self HashSetIter[K]) Fold(init K, f func(K, K) K) K
- func (self HashSetIter[K]) Map(f func(K) K) Iterator[K]
- func (self *HashSetIter[K]) Next() Option[K]
- func (self HashSetIter[K]) Rev() Iterator[K]
- type I128
- func (self I128) Abs() I128
- func (self I128) Add(rhs I128) I128
- func (self *I128) AddAssign(rhs I128)
- func (self I128) Cmp(rhs I128) Ordering
- func (self I128) Debug() String
- func (self I128) Display() String
- func (lhs I128) Div(rhs I128) I128
- func (self *I128) DivAssign(rhs I128)
- func (self I128) Eq(rhs I128) Bool
- func (self I128) IsNegative() Bool
- func (self I128) IsPositive() Bool
- func (self I128) Mul(rhs I128) I128
- func (self *I128) MulAssign(rhs I128)
- func (self I128) Neg() I128
- func (lhs I128) Rem(rhs I128) I128
- func (self *I128) RemAssign(rhs I128)
- func (lhs I128) Shl(rhs I128) I128
- func (lhs I128) Shr(rhs I128) I128
- func (self I128) Sub(rhs I128) I128
- func (self *I128) SubAssign(rhs I128)
- func (self I128) ToString() String
- type I16
- func (self I16) Abs() I16
- func (self I16) AbsDiff(other I16) U16
- func (self I16) Add(rhs I16) I16
- func (self *I16) AddAssign(rhs I16)
- func (self I16) AsRef() *I16
- func (self I16) CheckedAdd(rhs I16) Option[I16]
- func (self I16) CheckedDiv(rhs I16) Option[I16]
- func (self I16) CheckedMul(rhs I16) Option[I16]
- func (self I16) CheckedRem(rhs I16) Option[I16]
- func (self I16) CheckedSub(rhs I16) Option[I16]
- func (self I16) Clone() I16
- func (self I16) Cmp(rhs I16) Ordering
- func (self I16) Debug() String
- func (self I16) Display() String
- func (self I16) Div(rhs I16) I16
- func (self *I16) DivAssign(rhs I16)
- func (self I16) Eq(rhs I16) Bool
- func (self I16) IsNegative() Bool
- func (self I16) IsPositive() Bool
- func (self I16) Mul(rhs I16) I16
- func (self *I16) MulAssign(rhs I16)
- func (self I16) Neg(rhs I16) I16
- func (self I16) Pow(exp U32) I16
- func (self I16) Rem(rhs I16) I16
- func (self *I16) RemAssign(rhs I16)
- func (self I16) SaturatingAdd(rhs I16) I16
- func (self I16) SaturatingDiv(rhs I16) I16
- func (self I16) SaturatingMul(rhs I16) I16
- func (self I16) SaturatingSub(rhs I16) I16
- func (lhs I16) Shl(rhs I16) I16
- func (lhs I16) Shr(rhs I16) I16
- func (self I16) Sub(rhs I16) I16
- func (self *I16) SubAssign(rhs I16)
- func (self I16) ToString() String
- func (self I16) WrappingAdd(rhs I16) I16
- func (self I16) WrappingDiv(rhs I16) I16
- func (self I16) WrappingMul(rhs I16) I16
- func (self I16) WrappingSub(rhs I16) I16
- type I32
- func (self I32) Abs() I32
- func (self I32) AbsDiff(other I32) U32
- func (self I32) Add(rhs I32) I32
- func (self *I32) AddAssign(rhs I32)
- func (self I32) AsRef() *I32
- func (self I32) CheckedAdd(rhs I32) Option[I32]
- func (self I32) CheckedDiv(rhs I32) Option[I32]
- func (self I32) CheckedMul(rhs I32) Option[I32]
- func (self I32) CheckedRem(rhs I32) Option[I32]
- func (self I32) CheckedSub(rhs I32) Option[I32]
- func (self I32) Clone() I32
- func (self I32) Cmp(rhs I32) Ordering
- func (self I32) Debug() String
- func (self I32) Display() String
- func (self I32) Div(rhs I32) I32
- func (self *I32) DivAssign(rhs I32)
- func (self I32) Eq(rhs I32) Bool
- func (self I32) IsNegative() Bool
- func (self I32) IsPositive() Bool
- func (self I32) Mul(rhs I32) I32
- func (self *I32) MulAssign(rhs I32)
- func (self I32) Neg(rhs I32) I32
- func (self I32) Pow(exp U32) I32
- func (self I32) Rem(rhs I32) I32
- func (self *I32) RemAssign(rhs I32)
- func (self I32) SaturatingAdd(rhs I32) I32
- func (self I32) SaturatingDiv(rhs I32) I32
- func (self I32) SaturatingMul(rhs I32) I32
- func (self I32) SaturatingSub(rhs I32) I32
- func (lhs I32) Shl(rhs I32) I32
- func (lhs I32) Shr(rhs I32) I32
- func (self I32) Sub(rhs I32) I32
- func (self *I32) SubAssign(rhs I32)
- func (self I32) ToString() String
- func (self I32) WrappingAdd(rhs I32) I32
- func (self I32) WrappingDiv(rhs I32) I32
- func (self I32) WrappingMul(rhs I32) I32
- func (self I32) WrappingSub(rhs I32) I32
- type I64
- func (self I64) Abs() I64
- func (self I64) AbsDiff(other I64) U64
- func (self I64) Add(rhs I64) I64
- func (self *I64) AddAssign(rhs I64)
- func (self I64) AsRef() *I64
- func (self I64) CheckedAdd(rhs I64) Option[I64]
- func (self I64) CheckedDiv(rhs I64) Option[I64]
- func (self I64) CheckedMul(rhs I64) Option[I64]
- func (self I64) CheckedRem(rhs I64) Option[I64]
- func (self I64) CheckedSub(rhs I64) Option[I64]
- func (self I64) Clone() I64
- func (self I64) Cmp(rhs I64) Ordering
- func (self I64) Debug() String
- func (self I64) Display() String
- func (self I64) Div(rhs I64) I64
- func (self *I64) DivAssign(rhs I64)
- func (self I64) Eq(rhs I64) Bool
- func (self I64) IsNegative() Bool
- func (self I64) IsPositive() Bool
- func (self I64) Mul(rhs I64) I64
- func (self *I64) MulAssign(rhs I64)
- func (self I64) Neg(rhs I64) I64
- func (self I64) Pow(exp U32) I64
- func (self I64) Rem(rhs I64) I64
- func (self *I64) RemAssign(rhs I64)
- func (self I64) SaturatingAdd(rhs I64) I64
- func (self I64) SaturatingDiv(rhs I64) I64
- func (self I64) SaturatingMul(rhs I64) I64
- func (self I64) SaturatingSub(rhs I64) I64
- func (lhs I64) Shl(rhs I64) I64
- func (lhs I64) Shr(rhs I64) I64
- func (self I64) Sub(rhs I64) I64
- func (self *I64) SubAssign(rhs I64)
- func (self I64) ToString() String
- func (self I64) WrappingAdd(rhs I64) I64
- func (self I64) WrappingDiv(rhs I64) I64
- func (self I64) WrappingMul(rhs I64) I64
- func (self I64) WrappingSub(rhs I64) I64
- type I8
- func (self I8) Abs() I8
- func (self I8) AbsDiff(other I8) U8
- func (self I8) Add(rhs I8) I8
- func (self *I8) AddAssign(rhs I8)
- func (self I8) AsRef() *I8
- func (self I8) CheckedAdd(rhs I8) Option[I8]
- func (self I8) CheckedDiv(rhs I8) Option[I8]
- func (self I8) CheckedMul(rhs I8) Option[I8]
- func (self I8) CheckedRem(rhs I8) Option[I8]
- func (self I8) CheckedSub(rhs I8) Option[I8]
- func (self I8) Clone() I8
- func (self I8) Cmp(rhs I8) Ordering
- func (self I8) Debug() String
- func (self I8) Display() String
- func (self I8) Div(rhs I8) I8
- func (self *I8) DivAssign(rhs I8)
- func (self I8) Eq(rhs I8) Bool
- func (self I8) IsNegative() Bool
- func (self I8) IsPositive() Bool
- func (self I8) Mul(rhs I8) I8
- func (self *I8) MulAssign(rhs I8)
- func (self I8) Neg(rhs I8) I8
- func (self I8) Pow(exp U32) I8
- func (self I8) Rem(rhs I8) I8
- func (self *I8) RemAssign(rhs I8)
- func (self I8) SaturatingAdd(rhs I8) I8
- func (self I8) SaturatingDiv(rhs I8) I8
- func (self I8) SaturatingMul(rhs I8) I8
- func (self I8) SaturatingSub(rhs I8) I8
- func (lhs I8) Shl(rhs I8) I8
- func (lhs I8) Shr(rhs I8) I8
- func (self I8) Sub(rhs I8) I8
- func (self *I8) SubAssign(rhs I8)
- func (self I8) ToString() String
- func (self I8) WrappingAdd(rhs I8) I8
- func (self I8) WrappingDiv(rhs I8) I8
- func (self I8) WrappingMul(rhs I8) I8
- func (self I8) WrappingSub(rhs I8) I8
- type ISize
- func (self ISize) Abs() ISize
- func (self ISize) AbsDiff(other ISize) USize
- func (self ISize) Add(rhs ISize) ISize
- func (self *ISize) AddAssign(rhs ISize)
- func (self ISize) AsRef() *ISize
- func (self ISize) CheckedAdd(rhs ISize) Option[ISize]
- func (self ISize) CheckedDiv(rhs ISize) Option[ISize]
- func (self ISize) CheckedMul(rhs ISize) Option[ISize]
- func (self ISize) CheckedRem(rhs ISize) Option[ISize]
- func (self ISize) CheckedSub(rhs ISize) Option[ISize]
- func (self ISize) Clone() ISize
- func (self ISize) Cmp(rhs ISize) Ordering
- func (self ISize) Debug() String
- func (self ISize) Display() String
- func (self ISize) Div(rhs ISize) ISize
- func (self *ISize) DivAssign(rhs ISize)
- func (self ISize) Eq(rhs ISize) Bool
- func (self ISize) IsNegative() Bool
- func (self ISize) IsPositive() Bool
- func (self ISize) Mul(rhs ISize) ISize
- func (self *ISize) MulAssign(rhs ISize)
- func (self ISize) Neg(rhs ISize) ISize
- func (self ISize) Pow(exp U32) ISize
- func (self ISize) Rem(rhs ISize) ISize
- func (self *ISize) RemAssign(rhs ISize)
- func (self ISize) SaturatingAdd(rhs ISize) ISize
- func (self ISize) SaturatingDiv(rhs ISize) ISize
- func (self ISize) SaturatingMul(rhs ISize) ISize
- func (self ISize) SaturatingSub(rhs ISize) ISize
- func (lhs ISize) Shl(rhs ISize) ISize
- func (lhs ISize) Shr(rhs ISize) ISize
- func (self ISize) Sub(rhs ISize) ISize
- func (self *ISize) SubAssign(rhs ISize)
- func (self ISize) ToString() String
- func (self ISize) WrappingAdd(rhs ISize) ISize
- func (self ISize) WrappingDiv(rhs ISize) ISize
- func (self ISize) WrappingMul(rhs ISize) ISize
- func (self ISize) WrappingSub(rhs ISize) ISize
- type IntoIterator
- type Iterator
- type JoinHandle
- type LinkedList
- func (list *LinkedList[T]) Append(other *LinkedList[T])
- func (self LinkedList[T]) AsRef() *LinkedList[T]
- func (list *LinkedList[T]) Back() Option[*T]
- func (list *LinkedList[T]) Clear()
- func (self LinkedList[T]) Clone() LinkedList[T]
- func (self LinkedList[T]) Debug() String
- func (self LinkedList[T]) Display() String
- func (self LinkedList[T]) Eq(rhs LinkedList[T]) Bool
- func (list *LinkedList[T]) Front() Option[*T]
- func (list *LinkedList[T]) IntoIter() Iterator[T]
- func (list LinkedList[T]) IsEmpty() Bool
- func (list LinkedList[T]) Len() USize
- func (list *LinkedList[T]) PopBack() Option[T]
- func (list *LinkedList[T]) PopFront() Option[T]
- func (list *LinkedList[T]) PushBack(value T)
- func (list *LinkedList[T]) PushFront(value T)
- type LinkedListIter
- func (self LinkedListIter[T]) CollectToLinkedList() LinkedList[T]
- func (self LinkedListIter[T]) CollectToVec() Vec[T]
- func (self LinkedListIter[T]) Filter(f func(T) Bool) Iterator[T]
- func (self LinkedListIter[T]) Fold(init T, f func(T, T) T) T
- func (self LinkedListIter[T]) Map(f func(T) T) Iterator[T]
- func (self *LinkedListIter[T]) Next() Option[T]
- func (self LinkedListIter[T]) Rev() Iterator[T]
- type LinkedListNode
- type Mul
- type MulAssign
- type Mutex
- type Neg
- type Option
- func (self Option[T]) And(optb Option[any]) Option[any]
- func (self Option[T]) AndThen(f func(T) Option[any]) Option[any]
- func (self Option[T]) AsRef() *Option[T]
- func (self Option[T]) Clone() Option[T]
- func (self Option[T]) Debug() String
- func (self Option[T]) Display() String
- func (self Option[T]) Eq(rhs Option[T]) Bool
- func (self Option[T]) Expect(message string) T
- func (self Option[T]) Filter(predicate func(T) Bool) Option[T]
- func (self *Option[T]) GetOrInsert(value T) *T
- func (self *Option[T]) GetOrInsertWith(f func() T) *T
- func (self *Option[T]) Insert(value T) *T
- func (self Option[T]) IsNone() Bool
- func (self Option[T]) IsSome() Bool
- func (self *Option[T]) IsSomeAnd(f func(T) Bool) Bool
- func (self Option[T]) Map(f func(T) T) Option[T]
- func (self Option[T]) MapOr(defaultValue T, f func(T) T) T
- func (self Option[T]) MapOrElse(defaultValue func() T, f func(T) T) T
- func (self Option[T]) Or(optb Option[T]) Option[T]
- func (self Option[T]) OrElse(f func() Option[T]) Option[T]
- func (self *Option[T]) Replace(value T) Option[T]
- func (self *Option[T]) Take() Option[T]
- func (self Option[T]) Unwrap() T
- func (self Option[T]) UnwrapOr(value T) T
- func (self Option[T]) UnwrapOrElse(f func() T) T
- func (self Option[T]) Xor(optb Option[T]) Option[T]
- type Ord
- type Ordering
- type Pair
- type Rem
- type RemAssign
- type Result
- func Copy(from String, to String) Result[any]
- func CreateDir(path String) Result[any]
- func Err[T any](err error) Result[T]
- func Ok[T any](value T) Result[T]
- func Read(path String) Result[[]Byte]
- func ReadDir(path String) Result[Vec[DirEntry]]
- func ReadToString(path String) Result[String]
- func RemoveDir(path String) Result[any]
- func RemoveFile(path String) Result[any]
- func Rename(from String, to String) Result[any]
- func StringFromUTF16(bytes Vec[U16]) Result[String]
- func Write(path String, data []Byte) Result[any]
- func (self Result[T]) And(res Result[T]) Result[T]
- func (self Result[T]) AndThen(op func(T) Result[T]) Result[T]
- func (self Result[T]) AsRef() *Result[T]
- func (self Result[T]) Clone() Result[T]
- func (self Result[T]) Debug() String
- func (self Result[T]) Display() String
- func (self Result[T]) Eq(rhs Result[T]) Bool
- func (self Result[T]) Err() Option[error]
- func (self Result[T]) Expect(message string) T
- func (self Result[T]) ExpectErr(message string) error
- func (self Result[T]) IsErr() Bool
- func (self Result[T]) IsErrAnd(predicate func(error) Bool) Bool
- func (self Result[T]) IsOk() Bool
- func (self Result[T]) IsOkAnd(predicate func(T) Bool) Bool
- func (self Result[T]) Map(f func(T) T) Result[T]
- func (self Result[T]) MapErr(f func(error) error) Result[T]
- func (self Result[T]) MapOr(defaultValue T, f func(T) T) T
- func (self Result[T]) MapOrElse(defaultValue func() T, f func(T) T) T
- func (self Result[T]) Ok() Option[T]
- func (self Result[T]) Or(res Result[T]) Result[T]
- func (self Result[T]) OrElse(op func(error) Result[T]) Result[T]
- func (self Result[T]) Unwrap() T
- func (self Result[T]) UnwrapErr() error
- func (self Result[T]) UnwrapOr(defaultValue T) T
- func (self Result[T]) UnwrapOrElse(f func() T) T
- type Shl
- type Shr
- type Stdin
- type String
- func (self String) Add(rhs String) String
- func (self *String) AddAssign(rhs String)
- func (self String) AsRef() *String
- func (self String) Chars() Vec[Char]
- func (self String) Clone() String
- func (self String) Cmp(rhs String) Ordering
- func (self String) Contains(str String) bool
- func (self String) Debug() String
- func (self String) Display() String
- func (self String) Eq(rhs String) Bool
- func (self String) Find(str String) Option[USize]
- func (self String) IntoBytes() Vec[U8]
- func (self String) IsEmpty() bool
- func (self String) Len() USize
- func (self String) ParseF64() Result[F64]
- func (self String) ParseI64() Result[I64]
- func (self String) ParseU64() Result[U64]
- func (self *String) Pop() Option[Char]
- func (self *String) Push(c Char) String
- func (self String) Repeat(n USize) String
- func (self String) Replace(old String, new String) String
- func (self String) Split(str String) Vec[String]
- func (self String) ToLowercase() String
- func (self String) ToString() String
- func (self String) ToUppercase() String
- func (self String) Trim() String
- type Sub
- type SubAssign
- type ToString
- type TryLockError
- type U128
- func (self U128) Add(rhs U128) U128
- func (self *U128) AddAssign(rhs U128)
- func (self U128) Cmp(rhs U128) Ordering
- func (self U128) Debug() String
- func (self U128) Display() String
- func (lhs U128) Div(rhs U128) U128
- func (self *U128) DivAssign(rhs U128)
- func (self U128) Eq(rhs U128) Bool
- func (self U128) Mul(rhs U128) U128
- func (self *U128) MulAssign(rhs U128)
- func (lhs U128) Rem(rhs U128) U128
- func (self *U128) RemAssign(rhs U128)
- func (lhs U128) Shl(rhs U128) U128
- func (lhs U128) Shr(rhs U128) U128
- func (self U128) Sub(rhs U128) U128
- func (self *U128) SubAssign(rhs U128)
- func (self U128) ToString() String
- type U16
- func (self U16) AbsDiff(other U16) U16
- func (self U16) Add(rhs U16) U16
- func (self *U16) AddAssign(rhs U16)
- func (self U16) AsRef() *U16
- func (self U16) CheckedAdd(rhs U16) Option[U16]
- func (self U16) CheckedDiv(rhs U16) Option[U16]
- func (self U16) CheckedMul(rhs U16) Option[U16]
- func (self U16) CheckedRem(rhs U16) Option[U16]
- func (self U16) CheckedSub(rhs U16) Option[U16]
- func (self U16) Clone() U16
- func (self U16) Cmp(rhs U16) Ordering
- func (self U16) Debug() String
- func (self U16) Display() String
- func (self U16) Div(rhs U16) U16
- func (self *U16) DivAssign(rhs U16)
- func (self U16) Eq(rhs U16) Bool
- func (self U16) Mul(rhs U16) U16
- func (self *U16) MulAssign(rhs U16)
- func (self U16) Pow(exp U32) U16
- func (self U16) Rem(rhs U16) U16
- func (self *U16) RemAssign(rhs U16)
- func (self U16) SaturatingAdd(rhs U16) U16
- func (self U16) SaturatingDiv(rhs U16) U16
- func (self U16) SaturatingMul(rhs U16) U16
- func (self U16) SaturatingSub(rhs U16) U16
- func (lhs U16) Shl(rhs U16) U16
- func (lhs U16) Shr(rhs U16) U16
- func (self U16) Sub(rhs U16) U16
- func (self *U16) SubAssign(rhs U16)
- func (self U16) ToString() String
- func (self U16) WrappingAdd(rhs U16) U16
- func (self U16) WrappingDiv(rhs U16) U16
- func (self U16) WrappingMul(rhs U16) U16
- func (self U16) WrappingSub(rhs U16) U16
- type U32
- func (self U32) AbsDiff(other U32) U32
- func (self U32) Add(rhs U32) U32
- func (self *U32) AddAssign(rhs U32)
- func (self U32) AsRef() *U32
- func (self U32) CheckedAdd(rhs U32) Option[U32]
- func (self U32) CheckedDiv(rhs U32) Option[U32]
- func (self U32) CheckedMul(rhs U32) Option[U32]
- func (self U32) CheckedRem(rhs U32) Option[U32]
- func (self U32) CheckedSub(rhs U32) Option[U32]
- func (self U32) Clone() U32
- func (self U32) Cmp(rhs U32) Ordering
- func (self U32) Debug() String
- func (self U32) Display() String
- func (self U32) Div(rhs U32) U32
- func (self *U32) DivAssign(rhs U32)
- func (self U32) Eq(rhs U32) Bool
- func (self U32) Mul(rhs U32) U32
- func (self *U32) MulAssign(rhs U32)
- func (self U32) Pow(exp U32) U32
- func (self U32) Rem(rhs U32) U32
- func (self *U32) RemAssign(rhs U32)
- func (self U32) SaturatingAdd(rhs U32) U32
- func (self U32) SaturatingDiv(rhs U32) U32
- func (self U32) SaturatingMul(rhs U32) U32
- func (self U32) SaturatingSub(rhs U32) U32
- func (lhs U32) Shl(rhs U32) U32
- func (lhs U32) Shr(rhs U32) U32
- func (self U32) Sub(rhs U32) U32
- func (self *U32) SubAssign(rhs U32)
- func (self U32) ToString() String
- func (self U32) WrappingAdd(rhs U32) U32
- func (self U32) WrappingDiv(rhs U32) U32
- func (self U32) WrappingMul(rhs U32) U32
- func (self U32) WrappingSub(rhs U32) U32
- type U64
- func (self U64) AbsDiff(other U64) U64
- func (self U64) Add(rhs U64) U64
- func (self *U64) AddAssign(rhs U64)
- func (self U64) AsRef() *U64
- func (self U64) CheckedAdd(rhs U64) Option[U64]
- func (self U64) CheckedDiv(rhs U64) Option[U64]
- func (self U64) CheckedMul(rhs U64) Option[U64]
- func (self U64) CheckedRem(rhs U64) Option[U64]
- func (self U64) CheckedSub(rhs U64) Option[U64]
- func (self U64) Clone() U64
- func (self U64) Cmp(rhs U64) Ordering
- func (self U64) Debug() String
- func (self U64) Display() String
- func (self U64) Div(rhs U64) U64
- func (self *U64) DivAssign(rhs U64)
- func (self U64) Eq(rhs U64) Bool
- func (self U64) Mul(rhs U64) U64
- func (self *U64) MulAssign(rhs U64)
- func (self U64) Pow(exp U32) U64
- func (self U64) Rem(rhs U64) U64
- func (self *U64) RemAssign(rhs U64)
- func (self U64) SaturatingAdd(rhs U64) U64
- func (self U64) SaturatingDiv(rhs U64) U64
- func (self U64) SaturatingMul(rhs U64) U64
- func (self U64) SaturatingSub(rhs U64) U64
- func (lhs U64) Shl(rhs U64) U64
- func (lhs U64) Shr(rhs U64) U64
- func (self U64) Sub(rhs U64) U64
- func (self *U64) SubAssign(rhs U64)
- func (self U64) ToString() String
- func (self U64) WrappingAdd(rhs U64) U64
- func (self U64) WrappingDiv(rhs U64) U64
- func (self U64) WrappingMul(rhs U64) U64
- func (self U64) WrappingSub(rhs U64) U64
- type U8
- func (self U8) AbsDiff(other U8) U8
- func (self U8) Add(rhs U8) U8
- func (self *U8) AddAssign(rhs U8)
- func (self U8) AsRef() *U8
- func (self U8) CheckedAdd(rhs U8) Option[U8]
- func (self U8) CheckedDiv(rhs U8) Option[U8]
- func (self U8) CheckedMul(rhs U8) Option[U8]
- func (self U8) CheckedRem(rhs U8) Option[U8]
- func (self U8) CheckedSub(rhs U8) Option[U8]
- func (self U8) Clone() U8
- func (self U8) Cmp(rhs U8) Ordering
- func (self U8) Debug() String
- func (self U8) Display() String
- func (self U8) Div(rhs U8) U8
- func (self *U8) DivAssign(rhs U8)
- func (self U8) Eq(rhs U8) Bool
- func (self U8) Mul(rhs U8) U8
- func (self *U8) MulAssign(rhs U8)
- func (self U8) Pow(exp U32) U8
- func (self U8) Rem(rhs U8) U8
- func (self *U8) RemAssign(rhs U8)
- func (self U8) SaturatingAdd(rhs U8) U8
- func (self U8) SaturatingDiv(rhs U8) U8
- func (self U8) SaturatingMul(rhs U8) U8
- func (self U8) SaturatingSub(rhs U8) U8
- func (lhs U8) Shl(rhs U8) U8
- func (lhs U8) Shr(rhs U8) U8
- func (self U8) Sub(rhs U8) U8
- func (self *U8) SubAssign(rhs U8)
- func (self U8) ToString() String
- func (self U8) WrappingAdd(rhs U8) U8
- func (self U8) WrappingDiv(rhs U8) U8
- func (self U8) WrappingMul(rhs U8) U8
- func (self U8) WrappingSub(rhs U8) U8
- type USize
- func (self USize) AbsDiff(other USize) USize
- func (self USize) Add(rhs USize) USize
- func (self *USize) AddAssign(rhs USize)
- func (self USize) AsRef() *USize
- func (self USize) CheckedAdd(rhs USize) Option[USize]
- func (self USize) CheckedDiv(rhs USize) Option[USize]
- func (self USize) CheckedMul(rhs USize) Option[USize]
- func (self USize) CheckedRem(rhs USize) Option[USize]
- func (self USize) CheckedSub(rhs USize) Option[USize]
- func (self USize) Clone() USize
- func (self USize) Cmp(rhs USize) Ordering
- func (self USize) Debug() String
- func (self USize) Display() String
- func (self USize) Div(rhs USize) USize
- func (self *USize) DivAssign(rhs USize)
- func (self USize) Eq(rhs USize) Bool
- func (self USize) Mul(rhs USize) USize
- func (self *USize) MulAssign(rhs USize)
- func (self USize) Pow(exp U32) USize
- func (self USize) Rem(rhs USize) USize
- func (self *USize) RemAssign(rhs USize)
- func (self USize) SaturatingAdd(rhs USize) USize
- func (self USize) SaturatingDiv(rhs USize) USize
- func (self USize) SaturatingMul(rhs USize) USize
- func (self USize) SaturatingSub(rhs USize) USize
- func (lhs USize) Shl(rhs USize) USize
- func (lhs USize) Shr(rhs USize) USize
- func (self USize) Sub(rhs USize) USize
- func (self *USize) SubAssign(rhs USize)
- func (self USize) ToString() String
- func (self USize) WrappingAdd(rhs USize) USize
- func (self USize) WrappingDiv(rhs USize) USize
- func (self USize) WrappingMul(rhs USize) USize
- func (self USize) WrappingSub(rhs USize) USize
- type Unit
- type Vec
- func (self *Vec[T]) Append(other *Vec[T])
- func (self Vec[T]) AsRef() *Vec[T]
- func (self Vec[T]) AsSlice() []T
- func (self Vec[T]) BinarySearch(value T) Option[USize]
- func (self Vec[T]) BinarySearchBy(f func(T) Ordering) Option[USize]
- func (self Vec[T]) Capacity() USize
- func (self *Vec[T]) Clear()
- func (self Vec[T]) Clone() Vec[T]
- func (self Vec[T]) Contains(value T) Bool
- func (self Vec[T]) Debug() String
- func (self *Vec[T]) Dedup()
- func (self *Vec[T]) DedupByKey(key func(T) any)
- func (self Vec[T]) Display() String
- func (self Vec[T]) Eq(other Vec[T]) Bool
- func (self *Vec[T]) Fill(value T)
- func (self *Vec[T]) FillWith(f func() T)
- func (self Vec[T]) Get(index USize) Option[T]
- func (self Vec[T]) GetUnchecked(index USize) T
- func (self *Vec[T]) Insert(index USize, value T)
- func (self Vec[T]) IntoIter() Iterator[T]
- func (self Vec[T]) IsEmpty() Bool
- func (self Vec[T]) Len() USize
- func (self *Vec[T]) Pop() Option[T]
- func (self *Vec[T]) Push(value T)
- func (self *Vec[T]) Reserve(additional USize)
- func (self *Vec[T]) Retain(predicate func(T) Bool)
- func (self *Vec[T]) Reverse()
- func (self *Vec[T]) Set(index USize, value T) Option[T]
- func (self *Vec[T]) SetUnchecked(index USize, value T)
- func (self *Vec[T]) Sort()
- func (self *Vec[T]) SortBy(compare func(T, T) Ordering)
- func (self *Vec[T]) SortUnstable()
- func (self *Vec[T]) SortUnstableBy(compare func(T, T) Ordering)
- func (self *Vec[T]) Swap(a, b USize)
- type VecDeque
- func (self *VecDeque[T]) Append(other *VecDeque[T])
- func (self VecDeque[T]) AsRef() *VecDeque[T]
- func (self VecDeque[T]) AsSlice() []T
- func (self VecDeque[T]) Back() Option[T]
- func (self VecDeque[T]) BinarySearch(value T) Option[USize]
- func (self VecDeque[T]) BinarySearchBy(f func(T) Ordering) Option[USize]
- func (self VecDeque[T]) Capacity() USize
- func (self *VecDeque[T]) Clear()
- func (self VecDeque[T]) Clone() *VecDeque[T]
- func (self VecDeque[T]) Contains(value T) Bool
- func (self VecDeque[T]) Debug() String
- func (self *VecDeque[T]) Dedup(key func(T) any)
- func (self VecDeque[T]) Display() String
- func (self VecDeque[T]) Eq(other VecDeque[T]) Bool
- func (self *VecDeque[T]) Fill(value T)
- func (self *VecDeque[T]) FillWith(f func() T)
- func (self VecDeque[T]) Front() Option[T]
- func (self VecDeque[T]) Get(index USize) Option[T]
- func (self VecDeque[T]) GetUnchecked(index USize) T
- func (self VecDeque[T]) IntoIter() Iterator[T]
- func (self VecDeque[T]) IsEmpty() Bool
- func (self VecDeque[T]) Len() USize
- func (self *VecDeque[T]) PopBack() Option[T]
- func (self *VecDeque[T]) PopFront() Option[T]
- func (self *VecDeque[T]) PushBack(value T)
- func (self *VecDeque[T]) PushFront(value T)
- func (self *VecDeque[T]) Reserve(additional USize)
- func (self *VecDeque[T]) Retain(f func(T) Bool)
- func (self *VecDeque[T]) Set(index USize, value T) Option[T]
- func (self *VecDeque[T]) SetUnchecked(index USize, value T)
- func (self *VecDeque[T]) Sort()
- func (self *VecDeque[T]) SortBy(f func(T, T) Ordering)
- func (self *VecDeque[T]) SortUnstable()
- func (self *VecDeque[T]) SortUnstableBy(f func(T, T) Ordering)
- func (self *VecDeque[T]) Swap(a USize, b USize)
- type VecDequeIter
- func (self *VecDequeIter[T]) CollectToLinkedList() LinkedList[T]
- func (self *VecDequeIter[T]) CollectToVec() Vec[T]
- func (self *VecDequeIter[T]) Filter(f func(T) Bool) Iterator[T]
- func (self *VecDequeIter[T]) Fold(initial T, f func(T, T) T) T
- func (self *VecDequeIter[T]) Map(f func(T) T) Iterator[T]
- func (self *VecDequeIter[T]) Next() Option[T]
- func (self *VecDequeIter[T]) Rev() Iterator[T]
- type VecIter
- func (self VecIter[T]) CollectToLinkedList() LinkedList[T]
- func (self VecIter[T]) CollectToVec() Vec[T]
- func (self VecIter[T]) Filter(f func(T) Bool) Iterator[T]
- func (self VecIter[T]) Fold(init T, f func(T, T) T) T
- func (self VecIter[T]) Map(f func(T) T) Iterator[T]
- func (self *VecIter[T]) Next() Option[T]
- func (self VecIter[T]) Rev() Iterator[T]
- type Void
Constants ¶
const I16_MAX = I16(math.MaxInt16)
const I16_MIN = I16(math.MinInt16)
const I32_MAX = I32(math.MaxInt32)
const I32_MIN = I32(math.MinInt32)
const I64_MAX = I64(math.MaxInt64)
const I64_MIN = I64(math.MinInt64)
const I8_MAX = I8(math.MaxInt8)
const I8_MIN = I8(math.MinInt8)
const ISize_MAX = ISize(math.MaxInt)
const ISize_MIN = ISize(math.MinInt)
const U16_MAX = U16(math.MaxUint16)
const U16_MIN = U16(0)
const U32_MAX = U32(math.MaxUint32)
const U32_MIN = U32(0)
const U64_MAX = U64(math.MaxUint64)
const U64_MIN = U64(0)
const U8_MAX = U8(math.MaxUint8)
const U8_MIN = U8(0)
const USize_MAX = USize(math.MaxUint)
const USize_MIN = USize(0)
Variables ¶
var I128_MAX = I128{ // contains filtered or unexported fields }
var I128_MIN = I128{ // contains filtered or unexported fields }
var U128_MAX = U128{ // contains filtered or unexported fields }
var U128_MIN = U128{ // contains filtered or unexported fields }
Functions ¶
func Assert ¶ added in v0.7.3
Asserts that a boolean expression is true at runtime.
gost.Assert(true, "This is true")
func AssertEq ¶ added in v0.7.3
Asserts that two expressions are equal to each other
gost.AssertEq(1, 1, "These are equal")
func AssertNe ¶ added in v0.7.3
Asserts that two expressions are not equal to each other
gost.AssertNe(1, 2, "These are not equal")
func If ¶ added in v0.9.0
If-else statement.
n := I32(5) foo := If(n == 10, func() String { return "This is 10" }).ElseIf(n == 5, func() String { return "This is 5" }).Else(func() String { return "This is not 5 or 10" }) AssertEq(foo, String("This is 5"))
func Sleep ¶ added in v0.11.0
func Sleep(dur Duration)
Puts the current thread to sleep for at least the specified amount of time.
gost.Sleep(gost.DurationFromSecs(5)) // Sleep for 5 seconds
func Unimplemented ¶ added in v0.7.3
func Unimplemented(messages ...String)
Indicates unimplemented code by panicking with a message of “not implemented”.
gost.Unimplemented()
func Unreachable ¶ added in v0.7.3
func Unreachable(messages ...String)
Indicates unreachable code.
gost.Unreachable()
Types ¶
type Add ¶
type Add[T any] interface { Add(rhs T) T }
Add is a trait for types that support addition.
type AddAssign ¶
type AddAssign[T any] interface { AddAssign(rhs T) }
The addition assignment operator +=.
type AsRef ¶ added in v0.7.3
type AsRef[T any] interface { AsRef() *T }
Used to do a cheap reference-to-reference conversion.
type BTreeMap ¶ added in v0.7.0
An ordered map based on a B-Tree.
func BTreeMapNew ¶ added in v0.7.0
Creates an empty BTreeMap.
func (*BTreeMap[K, V]) Clear ¶ added in v0.7.0
func (self *BTreeMap[K, V]) Clear()
Clears the map, removing all elements.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) someMap.Clear() gost.AssertEq(someMap.IsEmpty(), gost.Bool(true))
func (*BTreeMap[K, V]) ContainsKey ¶ added in v0.7.0
Returns true if the map contains a value for the specified key. The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) gost.AssertEq(someMap.ContainsKey(gost.String("foo")), gost.Bool(true))
func (*BTreeMap[K, V]) Get ¶ added in v0.7.0
Returns value corresponding to the key.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) gost.AssertEq(someMap.Get(gost.String("foo")), Some[gost.I32](gost.I32(1)))
func (*BTreeMap[K, V]) Insert ¶ added in v0.7.0
Inserts a key-value pair into the map. If the map did not have this key present, None is returned. If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the module-level documentation for more.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() gost.AssertEq(someMap.Insert(gost.String("foo"), gost.I32(1)), None[gost.I32]()) gost.AssertEq(someMap.IsEmpty(), gost.Bool(false))) someMap.Insert(gost.String("foo"), gost.I32(2)) gost.AssertEq(someMap.Insert(gost.String("foo"), gost.I32(3)), Some[gost.I32](gost.I32(2)))
func (*BTreeMap[K, V]) IsEmpty ¶ added in v0.7.0
Returns true if the map contains no elements.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) gost.AssertEq(someMap.IsEmpty(), gost.Bool(false))
func (BTreeMap[K, V]) Keys ¶ added in v0.7.0
An iterator visiting all keys in arbitrary order. The iterator element type is K.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) someMap.Insert(gost.String("bar"), gost.I32(2)) someMap.Insert(gost.String("baz"), gost.I32(3)) keys := someMap.Keys().CollectToVec() gost.AssertEq(keys.Len(), gost.USize(3))
func (*BTreeMap[K, V]) Len ¶ added in v0.7.0
Returns the number of elements in the map.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) gost.AssertEq(someMap.Len(), gost.USize(1))
func (*BTreeMap[K, V]) Remove ¶ added in v0.7.0
Removes a key from the map, returning the value at the key if the key was previously in the map. The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) gost.AssertEq(someMap.Remove(gost.String("foo")), Some[gost.I32](gost.I32(1)))
func (BTreeMap[K, V]) Values ¶ added in v0.7.0
An iterator visiting all values in arbitrary order. The iterator element type is V.
someMap := gost.BTreeMapNew[gost.String, gost.I32]() someMap.Insert(gost.String("foo"), gost.I32(1)) someMap.Insert(gost.String("bar"), gost.I32(2)) someMap.Insert(gost.String("baz"), gost.I32(3)) values := someMap.Values().CollectToVec() gost.AssertEq(values.Len(), gost.USize(3))
type BTreeMapIter ¶ added in v0.7.0
func (BTreeMapIter[K, V]) CollectToLinkedList ¶ added in v0.7.0
func (self BTreeMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]
Collect to LinkedList
func (BTreeMapIter[K, V]) CollectToVec ¶ added in v0.7.0
func (self BTreeMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]
Collect to Vec
func (*BTreeMapIter[K, V]) Filter ¶ added in v0.7.0
func (self *BTreeMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]
filter
func (*BTreeMapIter[K, V]) Fold ¶ added in v0.7.0
func (self *BTreeMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]
fold
func (*BTreeMapIter[K, V]) Map ¶ added in v0.7.0
func (self *BTreeMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]
map
func (*BTreeMapIter[K, V]) Next ¶ added in v0.7.0
func (self *BTreeMapIter[K, V]) Next() Option[Pair[K, V]]
next
func (BTreeMapIter[K, V]) Rev ¶ added in v0.7.0
func (self BTreeMapIter[K, V]) Rev() Iterator[Pair[K, V]]
rev
type BTreeMapKeys ¶ added in v0.7.0
type BTreeMapKeys[K any] struct { // contains filtered or unexported fields }
An iterator visiting all keys in arbitrary order. The iterator element type is K.
func (BTreeMapKeys[K]) CollectToLinkedList ¶ added in v0.7.0
func (self BTreeMapKeys[K]) CollectToLinkedList() LinkedList[K]
Collect to LinkedList
func (BTreeMapKeys[K]) CollectToVec ¶ added in v0.7.0
func (self BTreeMapKeys[K]) CollectToVec() Vec[K]
Collect to Vec
func (*BTreeMapKeys[K]) Filter ¶ added in v0.7.0
func (self *BTreeMapKeys[K]) Filter(f func(K) Bool) Iterator[K]
filter
func (*BTreeMapKeys[K]) Fold ¶ added in v0.7.0
func (self *BTreeMapKeys[K]) Fold(init K, f func(K, K) K) K
fold
func (*BTreeMapKeys[K]) Map ¶ added in v0.7.0
func (self *BTreeMapKeys[K]) Map(f func(K) K) Iterator[K]
map
type BTreeMapValues ¶ added in v0.7.0
type BTreeMapValues[V any] struct { // contains filtered or unexported fields }
An iterator visiting all values in arbitrary order. The iterator element type is V.
func (BTreeMapValues[V]) CollectToLinkedList ¶ added in v0.7.0
func (self BTreeMapValues[V]) CollectToLinkedList() LinkedList[V]
Collect to LinkedList
func (BTreeMapValues[V]) CollectToVec ¶ added in v0.7.0
func (self BTreeMapValues[V]) CollectToVec() Vec[V]
Collect to Vec
func (*BTreeMapValues[V]) Filter ¶ added in v0.7.0
func (self *BTreeMapValues[V]) Filter(f func(V) Bool) Iterator[V]
filter
func (*BTreeMapValues[V]) Fold ¶ added in v0.7.0
func (self *BTreeMapValues[V]) Fold(init V, f func(V, V) V) V
fold
func (*BTreeMapValues[V]) Map ¶ added in v0.7.0
func (self *BTreeMapValues[V]) Map(f func(V) V) Iterator[V]
map
func (*BTreeMapValues[V]) Next ¶ added in v0.7.0
func (self *BTreeMapValues[V]) Next() Option[V]
next
type BTreeSet ¶ added in v0.7.0
type BTreeSet[K Ord[K]] struct { // contains filtered or unexported fields }
A ordered set based on a B-Tree.
func BTreeSetNew ¶ added in v0.7.0
Creates an empty BTreeSet.
func (*BTreeSet[K]) Clear ¶ added in v0.7.0
func (self *BTreeSet[K]) Clear()
Clears the set, removing all elements.
set := gost.BTreeSetNew[Int]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) set.Clear() gost.AssertEq(set.Len(), gost.USize(0))
func (*BTreeSet[K]) Contains ¶ added in v0.7.0
Returns true if the set contains an element equal to the value. The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.
set := gost.BTreeSetNew[Int]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.Assert(set.Contains(gost.I32(1))) gost.Assert(!set.Contains(gost.I32(3)))
func (*BTreeSet[K]) Insert ¶ added in v0.7.0
Adds a value to the set. Returns whether the value was newly inserted. That is: If the set did not previously contain an equal value, true is returned. If the set already contained an equal value, false is returned, and the entry is not updated.
set := gost.BTreeSetNew[Int]() gost.Assert(set.Insert(gost.I32(1))) gost.Assert(!set.Insert(gost.I32(1)))
func (BTreeSet[K]) Intersection ¶ added in v0.10.0
Visits the elements representing the intersection, i.e., the elements that are both in self and other, in ascending order.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(5)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) intersection := set1.Intersection(set2) gost.Assert(intersection.Len() == gost.USize(2)) gost.Assert(intersection.Contains(gost.I32(1))) gost.Assert(intersection.Contains(gost.I32(2)))
func (BTreeSet[K]) IsDisjoint ¶ added in v0.10.0
Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(3)) set2.Insert(gost.I32(4)) gost.Assert(set1.IsDisjoint(set2))
func (BTreeSet[K]) IsEmpty ¶ added in v0.7.0
Returns true if the set contains no elements.
set := gost.BTreeSetNew[Int]() gost.Assert(set.IsEmpty()) set.Insert(gost.I32(1)) gost.Assert(!set.IsEmpty())
func (BTreeSet[K]) IsSubset ¶ added in v0.10.0
Returns true if the set is a subset of another, i.e., other contains at least all the elements in self.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) gost.Assert(set1.IsSubset(set2)) gost.Assert(!set2.IsSubset(set1))
func (BTreeSet[K]) IsSuperset ¶ added in v0.10.0
Returns true if the set is a superset of another, i.e., self contains at least all the elements in other.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) gost.Assert(!set1.IsSuperset(set2)) gost.Assert(set2.IsSuperset(set1))
func (BTreeSet[K]) Len ¶ added in v0.7.0
Returns the number of elements in the set.
set := gost.BTreeSetNew[Int]() gost.AssertEq(set.Len(), gost.USize(0)) set.Insert(gost.I32(1)) gost.AssertEq(set.Len(), gost.USize(1))
func (*BTreeSet[K]) Remove ¶ added in v0.7.0
If the set contains an element equal to the value, removes it from the set and drops it. Returns whether such an element was present. The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.
set := gost.BTreeSetNew[Int]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.Assert(set.Remove(gost.I32(1))) gost.Assert(!set.Remove(gost.I32(3)))
func (BTreeSet[K]) SymmetricDifference ¶ added in v0.10.0
Visits the elements representing the symmetric difference, i.e., the elements that are in self or in other but not in both, in ascending order.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(5)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) symmetricDifference := set1.SymmetricDifference(set2) gost.Assert(symmetricDifference.Len() == gost.USize(2)) gost.Assert(symmetricDifference.Contains(gost.I32(3))) gost.Assert(symmetricDifference.Contains(gost.I32(5)))
func (BTreeSet[K]) Union ¶ added in v0.10.0
Visits the elements representing the union, i.e., all the elements in self or other, without duplicates, in ascending order.
set1 := gost.BTreeSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(3)) set2 := gost.BTreeSetNew[I32]() set2.Insert(gost.I32(3)) set2.Insert(gost.I32(4)) union := set1.Union(set2) gost.Assert(union.Len() == gost.USize(4)) gost.Assert(union.Contains(gost.I32(1))) gost.Assert(union.Contains(gost.I32(2))) gost.Assert(union.Contains(gost.I32(3))) gost.Assert(union.Contains(gost.I32(4)))
type BTreeSetIter ¶ added in v0.7.0
type BTreeSetIter[K Ord[K]] struct { // contains filtered or unexported fields }
Returns an iterator over the set.
func (BTreeSetIter[K]) CollectToLinkedList ¶ added in v0.7.0
func (self BTreeSetIter[K]) CollectToLinkedList() LinkedList[K]
Collect to LinkedList
func (BTreeSetIter[K]) CollectToVec ¶ added in v0.7.0
func (self BTreeSetIter[K]) CollectToVec() Vec[K]
Collect to Vec
func (BTreeSetIter[K]) Filter ¶ added in v0.7.0
func (self BTreeSetIter[K]) Filter(f func(K) Bool) Iterator[K]
filter
func (BTreeSetIter[K]) Fold ¶ added in v0.7.0
func (self BTreeSetIter[K]) Fold(init K, f func(K, K) K) K
fold
func (BTreeSetIter[K]) Map ¶ added in v0.7.0
func (self BTreeSetIter[K]) Map(f func(K) K) Iterator[K]
map
type BinaryHeap ¶ added in v0.9.0
type BinaryHeap[T Ord[T]] struct { // contains filtered or unexported fields }
A priority queue implemented with a binary heap. This will be a max-heap. It is a logic error for an item to be modified in such a way that the item’s ordering relative to any other item, as determined by the Ord trait, changes while it is in the heap. This is normally only possible through interior mutability, global state, I/O, or unsafe code. The behavior resulting from such a logic error is not specified, but will be encapsulated to the BinaryHeap that observed the logic error and not result in undefined behavior. This could include panics, incorrect results, aborts, memory leaks, and non-termination. As long as no elements change their relative order while being in the heap as described above, the API of BinaryHeap guarantees that the heap invariant remains intact i.e. its methods all behave as documented. For example if a method is documented as iterating in sorted order, that’s guaranteed to work as long as elements in the heap have not changed order, even in the presence of closures getting unwinded out of, iterators getting leaked, and similar foolishness.
func BinaryHeapNew ¶ added in v0.9.0
func BinaryHeapNew[T Ord[T]]() BinaryHeap[T]
Constructs a new, empty BinaryHeapNew<T>.
func BinaryHeapWithCapacity ¶ added in v0.9.0
func BinaryHeapWithCapacity[T Ord[T]](capacity USize) BinaryHeap[T]
Constructs a new, empty BinaryHeap<T> with at least the specified capacity.
func BinaryHeapWithLen ¶ added in v0.9.0
func BinaryHeapWithLen[T Ord[T]](len USize) BinaryHeap[T]
Constructs a new, empty BinaryHeap<T> with at least the specified len.
func (*BinaryHeap[T]) Append ¶ added in v0.9.0
func (self *BinaryHeap[T]) Append(other *BinaryHeap[T])
Moves all the elements of other into self, leaving other empty.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) heap.Push(2) heap.Push(3) heap2 := gost.BinaryHeapNew[gost.I32]() heap2.Push(4) heap2.Push(5) heap.Append(&heap2) gost.AssertEq(heap.Len(), gost.USize(5)) gost.AssertEq(heap2.Len(), gost.USize(0))
func (*BinaryHeap[T]) AsSlice ¶ added in v0.9.0
func (self *BinaryHeap[T]) AsSlice() []T
Extracts a slice containing the entire heap.
func (BinaryHeap[T]) Capacity ¶ added in v0.9.0
func (self BinaryHeap[T]) Capacity() USize
Returns the total number of elements the heap can hold without reallocating.
heap := gost.BinaryHeapNew[gost.I32]() gost.AssertEq(heap.Capacity(), gost.USize(0)) heap.Reserve(10) gost.AssertEq(heap.Capacity(), gost.USize(10))
func (*BinaryHeap[T]) Clear ¶ added in v0.9.0
func (self *BinaryHeap[T]) Clear()
Clears the heap, removing all values.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) heap.Push(2) heap.Push(3) heap.Clear() gost.AssertEq(heap.Len(), gost.USize(0))
func (*BinaryHeap[T]) IntoSortedVec ¶ added in v0.9.0
func (self *BinaryHeap[T]) IntoSortedVec() Vec[T]
Consumes the BinaryHeap and returns a vector in sorted (ascending) order.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) heap.Push(3) heap.Push(2) vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.AssertEq(heap.IntoSortedVec(), vec)
func (*BinaryHeap[T]) IntoVec ¶ added in v0.9.0
func (self *BinaryHeap[T]) IntoVec() Vec[T]
Consumes the BinaryHeap and returns the underlying vector in arbitrary order.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) heap.Push(2) heap.Push(3) vec := gost.VecNew[gost.I32]() vec.Push(3) vec.Push(1) vec.Push(2) gost.AssertEq(heap.IntoVec(), vec)
func (BinaryHeap[T]) IsEmpty ¶ added in v0.9.0
func (self BinaryHeap[T]) IsEmpty() Bool
Returns true if the heap contains no elements.
heap := gost.BinaryHeapNew[gost.I32]() gost.Assert(heap.IsEmpty()) heap.Push(1) gost.Assert(!heap.IsEmpty())
func (BinaryHeap[T]) Len ¶ added in v0.9.0
func (self BinaryHeap[T]) Len() USize
Returns the number of elements in the heap, also referred to as its ‘length’.
heap := gost.BinaryHeapNew[gost.I32]() gost.AssertEq(heap.Len(), gost.USize(0)) heap.Push(1) gost.AssertEq(heap.Len(), gost.USize(1))
func (*BinaryHeap[T]) Pop ¶ added in v0.9.0
func (self *BinaryHeap[T]) Pop() Option[T]
Removes the greatest item from the binary heap and returns it, or None if it is empty.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) heap.Push(2) heap.Push(3) gost.AssertEq(heap.Len(), gost.I32(3)) gost.AssertEq(heap.Pop(), gost.Some[gost.I32](3)) gost.AssertEq(heap.Len(), gost.I32(2))
func (*BinaryHeap[T]) Push ¶ added in v0.9.0
func (self *BinaryHeap[T]) Push(item T)
Pushes an item onto the binary heap.
heap := gost.BinaryHeapNew[gost.I32]() heap.Push(1) gost.AssertEq(heap.Len(), gost.USize(1))
func (*BinaryHeap[T]) Reserve ¶ added in v0.9.0
func (self *BinaryHeap[T]) Reserve(capacity USize)
Reserves capacity for at least additional more elements to be inserted in the given Vec<T>. The collection may reserve more space to speculatively avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
deque := gost.BinaryHeapNew[gost.I32]() gost.AssertEq(deque.Capacity(), gost.USize(0)) deque.Reserve(10) gost.AssertEq(deque.Capacity(), gost.USize(10))
type Clone ¶
type Clone[T any] interface { Clone() T }
A common trait for the ability to explicitly duplicate an object.
type Complex128 ¶
type Complex128 complex128
func (Complex128) Add ¶ added in v0.6.0
func (self Complex128) Add(rhs Complex128) Complex128
func (*Complex128) AddAssign ¶ added in v0.6.0
func (self *Complex128) AddAssign(rhs Complex128)
func (Complex128) AsRef ¶ added in v0.7.3
func (self Complex128) AsRef() *Complex128
func (Complex128) Clone ¶
func (self Complex128) Clone() Complex128
func (Complex128) Debug ¶
func (self Complex128) Debug() String
func (Complex128) Display ¶
func (self Complex128) Display() String
func (Complex128) Div ¶ added in v0.6.0
func (self Complex128) Div(rhs Complex128) Complex128
func (*Complex128) DivAssign ¶ added in v0.6.0
func (self *Complex128) DivAssign(rhs Complex128)
func (Complex128) Mul ¶ added in v0.6.0
func (self Complex128) Mul(rhs Complex128) Complex128
func (*Complex128) MulAssign ¶ added in v0.6.0
func (self *Complex128) MulAssign(rhs Complex128)
func (Complex128) Sub ¶ added in v0.6.0
func (self Complex128) Sub(rhs Complex128) Complex128
func (*Complex128) SubAssign ¶ added in v0.6.0
func (self *Complex128) SubAssign(rhs Complex128)
func (Complex128) ToString ¶
func (self Complex128) ToString() String
type Debug ¶
? formatting. Debug should format the output in a programmer-facing, debugging context.
type Default ¶
type Default[T any] interface { Default() T }
A trait for giving a type a useful default value.
type Div ¶
type Div[T any] interface { Div(rhs T) T }
Div is a trait for types that support division.
type DivAssign ¶
type DivAssign[T any] interface { DivAssign(rhs T) }
The division assignment operator /=.
type Duration ¶ added in v0.11.0
type Duration struct {
// contains filtered or unexported fields
}
A Duration type to represent a span of time, typically used for system timeouts. Each Duration is composed of a whole number of seconds and a fractional part represented in nanoseconds. If the underlying system does not support nanosecond-level precision, APIs binding a system timeout will typically round up the number of nanoseconds.
func DurationFromMicros ¶ added in v0.11.0
Creates a new Duration from the specified number of microseconds.
func DurationFromMillis ¶ added in v0.11.0
Creates a new Duration from the specified number of milliseconds.
func DurationFromNanos ¶ added in v0.11.0
Creates a new Duration from the specified number of nanoseconds.
func DurationFromSecs ¶ added in v0.11.0
Creates a new Duration from the specified number of whole seconds.
func DurationNew ¶ added in v0.11.0
Creates a new Duration from the specified number of whole seconds and additional nanoseconds. If the number of nanoseconds is greater than 1 billion (the number of nanoseconds in a second), then it will carry over into the seconds provided.
func (Duration) AsMicros ¶ added in v0.11.0
Returns the total number of whole microseconds contained by this Duration.
func (Duration) AsMillis ¶ added in v0.11.0
Returns the total number of whole milliseconds contained by this Duration.
func (Duration) AsNanos ¶ added in v0.11.0
Returns the total number of nanoseconds contained by this Duration.
func (Duration) AsSecs ¶ added in v0.11.0
Returns the number of whole seconds contained by this Duration. The returned value does not include the fractional (nanosecond) part of the duration, which can be obtained using subsec_nanos.
func (Duration) SubsecMicros ¶ added in v0.11.0
Returns the fractional part of this Duration, in whole microseconds. This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).
func (Duration) SubsecMillis ¶ added in v0.11.0
Returns the fractional part of this Duration, in whole milliseconds. This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).
func (Duration) SubsecNanos ¶ added in v0.11.0
Returns the fractional part of this Duration, in nanoseconds. This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).
type F32 ¶ added in v0.6.0
type F32 float32
func (F32) Abs ¶ added in v0.10.0
Computes the absolute value of self.
f := gost.F32(-3.0) g := gost.F32(3.0) gost.AssertEq(f.Abs(), F32(3.0)) gost.AssertEq(g.Abs(), F32(3.0))
func (F32) Ceil ¶ added in v0.10.0
Returns the smallest integer greater than or equal to self.
f := gost.F32(3.01) g := gost.F32(4.0) gost.AssertEq(f.Ceil(), F32(4.0)) gost.AssertEq(g.Ceil(), F32(4.0))
func (F32) Exp ¶ added in v0.10.0
Returns e^(self), (the exponential function).
f := gost.F32(1.0) g := gost.F32(2.0) gost.AssertEq(f.Exp(), F32(2.7182817)) gost.AssertEq(g.Exp(), F32(7.389056))
func (F32) Exp2 ¶ added in v0.10.0
Returns 2^(self).
f := gost.F32(1.0) g := gost.F32(2.0) gost.AssertEq(f.Exp2(), F32(2.0)) gost.AssertEq(g.Exp2(), F32(4.0))
func (F32) Floor ¶ added in v0.10.0
Returns the largest integer less than or equal to self.
f := gost.F32(3.7) g := gost.F32(3.0) h := gost.F32(-3.7) gost.AssertEq(f.Floor(), F32(3.0)) gost.AssertEq(g.Floor(), F32(3.0)) gost.AssertEq(h.Floor(), F32(-4.0))
func (F32) Frac ¶ added in v0.10.0
Returns the fractional part of self.
f := gost.F32(3.7) g := gost.F32(-3.7) gost.AssertEq(f.Frac(), F32(0.7)) gost.AssertEq(g.Frac(), F32(-0.7))
func (F32) Ln ¶ added in v0.10.0
Returns the natural logarithm of the number.
f := gost.F32(2.7182817) g := gost.F32(7.389056) gost.AssertEq(f.Ln(), F32(1.0)) gost.AssertEq(g.Ln(), F32(2.0))
func (F32) Log ¶ added in v0.10.0
Returns the logarithm of the number with respect to an arbitrary base. The result might not be correctly rounded owing to implementation details; self.log2() can produce more accurate results for base 2, and self.log10() can produce more accurate results for base 10.
f := gost.F32(2.0) g := gost.F32(4.0) gost.AssertEq(f.Log(2.0), F32(1.0)) gost.AssertEq(g.Log(2.0), F32(2.0))
func (F32) Log10 ¶ added in v0.10.0
Returns the base 10 logarithm of the number.
f := gost.F32(10.0) g := gost.F32(100.0) gost.AssertEq(f.Log10(), F32(1.0)) gost.AssertEq(g.Log10(), F32(2.0))
func (F32) Log2 ¶ added in v0.10.0
Returns the base 2 logarithm of the number.
f := gost.F32(2.0) g := gost.F32(4.0) gost.AssertEq(f.Log2(), F32(1.0)) gost.AssertEq(g.Log2(), F32(2.0))
func (F32) Powf ¶ added in v0.10.0
Raises a number to a floating point power.
f := gost.F32(3.0) g := gost.F32(3.0) gost.AssertEq(f.Powf(2.0), F32(9.0)) gost.AssertEq(g.Powf(3.0), F32(27.0))
func (F32) Powi ¶ added in v0.10.0
Raises a number to an integer power. Using this function is generally faster than using powf. It might have a different sequence of rounding operations than powf, so the results are not guaranteed to agree.
f := gost.F32(3.0) g := gost.F32(3.0) gost.AssertEq(f.Powi(2), F32(9.0)) gost.AssertEq(g.Powi(3), F32(27.0))
func (F32) Round ¶ added in v0.10.0
Returns the nearest integer to self. If a value is half-way between two integers, round away from 0.0.
f := gost.F32(3.3) g := gost.F32(-3.3) h := gost.F32(-3.7) i := gost.F32(3.5) j := gost.F32(4.5) gost.AssertEq(f.Round(), F32(3.0)) gost.AssertEq(g.Round(), F32(-3.0)) gost.AssertEq(h.Round(), F32(-4.0)) gost.AssertEq(i.Round(), F32(4.0)) gost.AssertEq(j.Round(), F32(5.0))
type F64 ¶ added in v0.6.0
type F64 float64
func (F64) Abs ¶ added in v0.10.0
Computes the absolute value of self.
f := gost.F64(-3.0) g := gost.F64(3.0) gost.AssertEq(f.Abs(), F64(3.0)) gost.AssertEq(g.Abs(), F64(3.0))
func (F64) Ceil ¶ added in v0.10.0
Returns the smallest integer greater than or equal to self.
f := gost.F64(3.01) g := gost.F64(4.0) gost.AssertEq(f.Ceil(), F64(4.0)) gost.AssertEq(g.Ceil(), F64(4.0))
func (F64) Exp ¶ added in v0.10.0
Returns e^(self), (the exponential function).
f := gost.F64(1.0) g := gost.F64(2.0) gost.AssertEq(f.Exp(), F64(2.718281828459045)) gost.AssertEq(g.Exp(), F64(7.38905609893065))
func (F64) Exp2 ¶ added in v0.10.0
Returns 2^(self).
f := gost.F64(1.0) g := gost.F64(2.0) gost.AssertEq(f.Exp2(), F64(2.0)) gost.AssertEq(g.Exp2(), F64(4.0))
func (F64) Floor ¶ added in v0.10.0
Returns the largest integer less than or equal to self.
f := gost.F64(3.7) g := gost.F64(3.0) h := gost.F64(-3.7) gost.AssertEq(f.Floor(), F64(3.0)) gost.AssertEq(g.Floor(), F64(3.0)) gost.AssertEq(h.Floor(), F64(-4.0))
func (F64) Frac ¶ added in v0.10.0
Returns the fractional part of self.
f := gost.F64(3.7) g := gost.F64(-3.7) gost.AssertEq(f.Frac(), F64(0.7)) gost.AssertEq(g.Frac(), F64(-0.7))
func (F64) Ln ¶ added in v0.10.0
Returns the natural logarithm of the number.
f := gost.F64(2.718281828459045) g := gost.F64(7.38905609893065) gost.AssertEq(f.Ln(), F64(1.0)) gost.AssertEq(g.Ln(), F64(2.0))
func (F64) Log ¶ added in v0.10.0
Returns the logarithm of the number with respect to an arbitrary base. The result might not be correctly rounded owing to implementation details; self.log2() can produce more accurate results for base 2, and self.log10() can produce more accurate results for base 10.
f := gost.F64(2.0) g := gost.F64(4.0) gost.AssertEq(f.Log(2.0), F64(1.0)) gost.AssertEq(g.Log(2.0), F64(2.0))
func (F64) Log10 ¶ added in v0.10.0
Returns the base 10 logarithm of the number.
f := gost.F64(10.0) g := gost.F64(100.0) gost.AssertEq(f.Log10(), F64(1.0)) gost.AssertEq(g.Log10(), F64(2.0))
func (F64) Log2 ¶ added in v0.10.0
Returns the base 2 logarithm of the number.
f := gost.F64(2.0) g := gost.F64(4.0) gost.AssertEq(f.Log2(), F64(1.0)) gost.AssertEq(g.Log2(), F64(2.0))
func (F64) Powf ¶ added in v0.10.0
Raises a number to a floating point power.
f := gost.F64(3.0) g := gost.F64(3.0) gost.AssertEq(f.Powf(2.0), F64(9.0)) gost.AssertEq(g.Powf(3.0), F64(27.0))
func (F64) Powi ¶ added in v0.10.0
Raises a number to an integer power. Using this function is generally faster than using powf. It might have a different sequence of rounding operations than powf, so the results are not guaranteed to agree.
f := gost.F64(3.0) g := gost.F64(3.0) gost.AssertEq(f.Powi(2), F64(9.0)) gost.AssertEq(g.Powi(3), F64(27.0))
func (F64) Round ¶ added in v0.10.0
Returns the nearest integer to self. If a value is half-way between two integers, round away from 0.0.
f := gost.F64(3.3) g := gost.F64(-3.3) h := gost.F64(-3.7) i := gost.F64(3.5) j := gost.F64(4.5) gost.AssertEq(f.Round(), F64(3.0)) gost.AssertEq(g.Round(), F64(-3.0)) gost.AssertEq(h.Round(), F64(-4.0)) gost.AssertEq(i.Round(), F64(4.0)) gost.AssertEq(j.Round(), F64(5.0))
type Future ¶ added in v0.9.0
type Future[T any] interface { Await() T }
A future represents an asynchronous computation obtained by use of async.
type HashMap ¶
type HashMap[K comparable, V any] struct { // contains filtered or unexported fields }
A hash map
func HashMapWithCapacity ¶
func HashMapWithCapacity[K comparable, V any](capacity USize) HashMap[K, V]
Creates an empty HashMap with at least the specified capacity.
func (*HashMap[K, V]) Clear ¶
func (self *HashMap[K, V]) Clear()
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
map := gost.HashMapNew[Int, Int]() map.Insert(gost.I32(1), gost.I32(2)) map.Clear() gost.Assert(map.IsEmpty())
func (HashMap[K, V]) ContainsKey ¶
Returns true if the map contains a value for the specified key.
map := gost.HashMapNew[Int, Int]() map.Insert(gost.I32(1), gost.I32(2)) gost.Assert(map.ContainsKey(gost.I32(1))) gost.Assert(!map.ContainsKey(gost.I32(3)))
func (HashMap[K, V]) Get ¶
Returns value corresponding to the key.
map := gost.HashMapNew[Int, Int]() map.Insert(gost.I32(1), gost.I32(2)) gost.AssertEq(map.Get(gost.I32(1)), gost.Some[gost.I32](gost.I32(2)))
func (*HashMap[K, V]) Insert ¶
Inserts a key-value pair into the map. If the map did not have this key present, None is returned.
map := gost.HashMapNew[Int, Int]() gost.Assert(map.Insert(gost.I32(1), gost.I32(2)).IsNone()) gost.AssertEq(map.Insert(gost.I32(1), gost.I32(3)), gost.Some[gost.I32](gost.I32(2)))
func (HashMap[K, V]) IsEmpty ¶
Returns true if the map contains no elements.
map := gost.HashMapNew[Int, Int]() gost.Assert(map.IsEmpty()) map.Insert(gost.I32(1), gost.I32(2)) gost.Assert(!map.IsEmpty())
func (HashMap[K, V]) Keys ¶
An iterator visiting all keys in arbitrary order. The iterator element type is K.
map := gost.HashMapNew[Int, Int]() map.Insert(gost.I32(1), gost.I32(2)) map.Insert(gost.I32(3), gost.I32(4)) map.Insert(gost.I32(5), gost.I32(6)) keys := map.Keys() gost.AssertEq(keys.Next(), gost.Some[gost.I32](gost.I32(1)))
func (HashMap[K, V]) Len ¶
Returns the number of elements in the map.
map := gost.HashMapNew[Int, Int]() gost.AssertEq(map.Len(), gost.USize(0)) map.Insert(gost.I32(1), gost.I32(2)) gost.AssertEq(map.Len(), gost.USize(1))
func (*HashMap[K, V]) Remove ¶
Removes a key from the map, returning the value at the key if the key was previously in the map.
map := gost.HashMapNew[Int, Int]() gost.Assert(map.Insert(gost.I32(1), gost.I32(2)).IsNone()) gost.AssertEq(map.Insert(gost.I32(1), gost.I32(3)), gost.Some[gost.I32](gost.I32(2)))
type HashMapIter ¶
type HashMapIter[K comparable, V any] struct { // contains filtered or unexported fields }
Returns true if the map contains a value for the specified value.
func (HashMapIter[K, V]) CollectToLinkedList ¶ added in v0.6.0
func (self HashMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]
Collect to LinkedList
func (HashMapIter[K, V]) CollectToVec ¶
func (self HashMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]
Collect to Vec
func (HashMapIter[K, V]) Filter ¶
func (self HashMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]
filter
func (HashMapIter[K, V]) Fold ¶
func (self HashMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]
fold
type HashMapKeys ¶
type HashMapKeys[K any] struct { // contains filtered or unexported fields }
An iterator visiting all keys in arbitrary order. The iterator element type is K.
func (HashMapKeys[K]) CollectToLinkedList ¶ added in v0.6.0
func (self HashMapKeys[K]) CollectToLinkedList() LinkedList[K]
Collect to LinkedList
func (HashMapKeys[K]) CollectToVec ¶
func (self HashMapKeys[K]) CollectToVec() Vec[K]
Collect to Vec
type HashMapValues ¶
type HashMapValues[V any] struct { // contains filtered or unexported fields }
An iterator visiting all values in arbitrary order. The iterator element type is V.
func (HashMapValues[V]) CollectToLinkedList ¶ added in v0.6.0
func (self HashMapValues[V]) CollectToLinkedList() LinkedList[V]
Collect to LinkedList
func (HashMapValues[V]) CollectToVec ¶
func (self HashMapValues[V]) CollectToVec() Vec[V]
Collect to Vec
func (HashMapValues[V]) Filter ¶
func (self HashMapValues[V]) Filter(f func(V) Bool) Iterator[V]
filter
type HashSet ¶ added in v0.7.0
type HashSet[K comparable] struct { // contains filtered or unexported fields }
A unordered set based on a HashMap.
func HashSetFromSlice ¶ added in v0.7.0
func HashSetFromSlice[K comparable](slice []K) HashSet[K]
From Slice
func HashSetNew ¶ added in v0.7.0
func HashSetNew[K comparable]() HashSet[K]
Creates an empty HashSet.
func HashSetWithCapacity ¶ added in v0.7.0
func HashSetWithCapacity[K comparable](capacity USize) HashSet[K]
Creates an empty HashSet with at least the specified capacity.
func (*HashSet[K]) Clear ¶ added in v0.7.0
func (self *HashSet[K]) Clear()
Clears the set, removing all values.
set := gost.HashSetNew[gost.I32]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) set.Clear() gost.Assert(set.IsEmpty())
func (HashSet[K]) Contains ¶ added in v0.7.0
Returns true if the set contains a value. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.
set := gost.HashSetNew[gost.I32]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.Assert(set.Contains(gost.I32(1))) gost.Assert(!set.Contains(gost.I32(3)))
func (HashSet[K]) Get ¶ added in v0.7.0
Returns a reference to the value in the set, if any, that is equal to the given value. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.
set := gost.HashSetNew[gost.I32]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.Assert(set.Get(gost.I32(1)).IsSome()) gost.Assert(set.Get(gost.I32(3)).IsNone())
func (*HashSet[K]) Insert ¶ added in v0.7.0
Adds a value to the set. Returns whether the value was newly inserted. That is: If the set did not previously contain this value, true is returned. If the set already contained this value, false is returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.
set := gost.HashSetNew[gost.I32]() gost.Assert(set.Insert(gost.I32(1))) gost.Assert(!set.Insert(gost.I32(1)))
func (HashSet[K]) Intersection ¶ added in v0.10.0
Visits the elements representing the intersection, i.e., the elements that are both in self and other, in ascending order.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(5)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) intersection := set1.Intersection(set2) gost.Assert(intersection.Len() == gost.USize(2)) gost.Assert(intersection.Contains(gost.I32(1))) gost.Assert(intersection.Contains(gost.I32(2)))
func (HashSet[K]) IsDisjoint ¶ added in v0.10.0
Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(3)) set2.Insert(gost.I32(4)) gost.Assert(set1.IsDisjoint(set2))
func (HashSet[K]) IsEmpty ¶ added in v0.7.0
Returns true if the set contains no elements.
set := gost.HashSetNew[gost.I32]() gost.Assert(set.IsEmpty()) set.Insert(gost.I32(1)) gost.Assert(!set.IsEmpty())
func (HashSet[K]) IsSubset ¶ added in v0.10.0
Returns true if the set is a subset of another, i.e., other contains at least all the elements in self.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) gost.Assert(set1.IsSubset(set2)) gost.Assert(!set2.IsSubset(set1))
func (HashSet[K]) IsSuperset ¶ added in v0.10.0
Returns true if the set is a superset of another, i.e., self contains at least all the elements in other.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) gost.Assert(!set1.IsSuperset(set2)) gost.Assert(set2.IsSuperset(set1))
func (HashSet[K]) Len ¶ added in v0.7.0
Returns the number of elements in the set.
set := gost.HashSetNew[gost.I32]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.AssertEq(set.Len(), gost.USize(2))
func (*HashSet[K]) Remove ¶ added in v0.7.0
Removes a value from the set. Returns whether the value was present in the set. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.
set := gost.HashSetNew[gost.I32]() set.Insert(gost.I32(1)) set.Insert(gost.I32(2)) gost.Assert(set.Remove(gost.I32(1))) gost.Assert(!set.Remove(gost.I32(3)))
func (HashSet[K]) SymmetricDifference ¶ added in v0.10.0
Visits the elements representing the symmetric difference, i.e., the elements that are in self or in other but not in both, in ascending order.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(5)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(1)) set2.Insert(gost.I32(2)) set2.Insert(gost.I32(3)) symmetricDifference := set1.SymmetricDifference(set2) gost.Assert(symmetricDifference.Len() == gost.USize(2)) gost.Assert(symmetricDifference.Contains(gost.I32(3))) gost.Assert(symmetricDifference.Contains(gost.I32(5)))
func (HashSet[K]) Union ¶ added in v0.10.0
Visits the elements representing the union, i.e., all the elements in self or other, without duplicates, in ascending order.
set1 := gost.HashSetNew[I32]() set1.Insert(gost.I32(1)) set1.Insert(gost.I32(2)) set1.Insert(gost.I32(3)) set2 := gost.HashSetNew[I32]() set2.Insert(gost.I32(3)) set2.Insert(gost.I32(4)) union := set1.Union(set2) gost.Assert(union.Len() == gost.USize(4)) gost.Assert(union.Contains(gost.I32(1))) gost.Assert(union.Contains(gost.I32(2))) gost.Assert(union.Contains(gost.I32(3))) gost.Assert(union.Contains(gost.I32(4)))
type HashSetIter ¶ added in v0.7.0
type HashSetIter[K comparable] struct { // contains filtered or unexported fields }
Returns true if the set contains an element equal to the value.
func (HashSetIter[K]) CollectToLinkedList ¶ added in v0.7.0
func (self HashSetIter[K]) CollectToLinkedList() LinkedList[K]
Collect to LinkedList
func (HashSetIter[K]) CollectToVec ¶ added in v0.7.0
func (self HashSetIter[K]) CollectToVec() Vec[K]
Collect to Vec
func (HashSetIter[K]) Filter ¶ added in v0.7.0
func (self HashSetIter[K]) Filter(f func(K) Bool) Iterator[K]
filter
func (HashSetIter[K]) Fold ¶ added in v0.7.0
func (self HashSetIter[K]) Fold(init K, f func(K, K) K) K
fold
func (HashSetIter[K]) Map ¶ added in v0.7.0
func (self HashSetIter[K]) Map(f func(K) K) Iterator[K]
map
type I128 ¶ added in v0.11.0
type I128 struct {
// contains filtered or unexported fields
}
func I128_FromI64 ¶ added in v0.11.0
func I128_FromU64 ¶ added in v0.11.0
func (I128) IsNegative ¶ added in v0.11.0
Returns true if self is negative and false if the number is zero or positive.
func (I128) IsPositive ¶ added in v0.11.0
Returns true if self is positive and false if the number is zero or negative.
type I16 ¶ added in v0.6.0
type I16 int16
func (I16) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (I16) IsNegative ¶ added in v0.10.0
Returns true if self is negative and false if the number is zero or positive.
func (I16) IsPositive ¶ added in v0.10.0
Returns true if self is positive and false if the number is zero or negative.
func (I16) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (I16) SaturatingAdd ¶ added in v0.10.0
func (I16) SaturatingDiv ¶ added in v0.10.0
func (I16) SaturatingMul ¶ added in v0.10.0
func (I16) SaturatingSub ¶ added in v0.9.0
func (I16) WrappingAdd ¶ added in v0.8.0
func (I16) WrappingDiv ¶ added in v0.9.0
func (I16) WrappingMul ¶ added in v0.9.0
func (I16) WrappingSub ¶ added in v0.8.0
type I32 ¶ added in v0.6.0
type I32 int32
func (I32) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (I32) IsNegative ¶ added in v0.10.0
Returns true if self is negative and false if the number is zero or positive.
func (I32) IsPositive ¶ added in v0.10.0
Returns true if self is positive and false if the number is zero or negative.
func (I32) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (I32) SaturatingAdd ¶ added in v0.10.0
func (I32) SaturatingDiv ¶ added in v0.10.0
func (I32) SaturatingMul ¶ added in v0.10.0
func (I32) SaturatingSub ¶ added in v0.9.0
func (I32) WrappingAdd ¶ added in v0.8.0
func (I32) WrappingDiv ¶ added in v0.9.0
func (I32) WrappingMul ¶ added in v0.9.0
func (I32) WrappingSub ¶ added in v0.8.0
type I64 ¶ added in v0.6.0
type I64 int64
func (I64) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (I64) IsNegative ¶ added in v0.10.0
Returns true if self is negative and false if the number is zero or positive.
func (I64) IsPositive ¶ added in v0.10.0
Returns true if self is positive and false if the number is zero or negative.
func (I64) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (I64) SaturatingAdd ¶ added in v0.10.0
func (I64) SaturatingDiv ¶ added in v0.10.0
func (I64) SaturatingMul ¶ added in v0.10.0
func (I64) SaturatingSub ¶ added in v0.9.0
func (I64) WrappingAdd ¶ added in v0.8.0
func (I64) WrappingDiv ¶ added in v0.9.0
func (I64) WrappingMul ¶ added in v0.9.0
func (I64) WrappingSub ¶ added in v0.8.0
type I8 ¶ added in v0.6.0
type I8 int8
func (I8) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (I8) IsNegative ¶ added in v0.10.0
Returns true if self is negative and false if the number is zero or positive.
func (I8) IsPositive ¶ added in v0.10.0
Returns true if self is positive and false if the number is zero or negative.
func (I8) SaturatingAdd ¶ added in v0.10.0
func (I8) SaturatingDiv ¶ added in v0.10.0
func (I8) SaturatingMul ¶ added in v0.10.0
func (I8) SaturatingSub ¶ added in v0.9.0
func (I8) WrappingAdd ¶ added in v0.8.0
func (I8) WrappingDiv ¶ added in v0.9.0
func (I8) WrappingMul ¶ added in v0.9.0
func (I8) WrappingSub ¶ added in v0.8.0
type ISize ¶ added in v0.6.0
type ISize int
func (ISize) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (ISize) CheckedAdd ¶ added in v0.9.0
Checked integer addition. Computes self + rhs, returning None if overflow occurred.
func (ISize) CheckedDiv ¶ added in v0.9.0
Checked integer division. Computes self / rhs, returning None if rhs == 0 or the operation results in overflow.
func (ISize) CheckedMul ¶ added in v0.9.0
Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.
func (ISize) CheckedRem ¶ added in v0.9.0
Checked integer remainder. Computes self % rhs, returning None if rhs == 0 or the operation results in overflow.
func (ISize) CheckedSub ¶ added in v0.9.0
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.
func (ISize) IsNegative ¶ added in v0.10.0
Returns true if self is negative and false if the number is zero or positive.
func (ISize) IsPositive ¶ added in v0.10.0
Returns true if self is positive and false if the number is zero or negative.
func (ISize) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (ISize) SaturatingAdd ¶ added in v0.10.0
Saturating integer addition. Computes self + rhs, saturating at the numeric bounds instead of overflowing.
func (ISize) SaturatingDiv ¶ added in v0.10.0
Saturating integer division. Computes self / rhs, saturating at the numeric bounds instead of overflowing.
func (ISize) SaturatingMul ¶ added in v0.10.0
Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds instead of overflowing.
func (ISize) SaturatingSub ¶ added in v0.9.0
Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds instead of overflowing.
func (ISize) WrappingAdd ¶ added in v0.8.0
Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.
func (ISize) WrappingDiv ¶ added in v0.9.0
Wrapping (modular) division. Computes self / rhs, wrapping around at the boundary of the type.
func (ISize) WrappingMul ¶ added in v0.9.0
Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.
func (ISize) WrappingSub ¶ added in v0.8.0
Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.
type IntoIterator ¶
type JoinHandle ¶ added in v0.11.0
type JoinHandle struct {
// contains filtered or unexported fields
}
An owned permission to join on a thread (block on its termination).
func Spawn ¶ added in v0.11.0
func Spawn(f func()) JoinHandle
Spawns a new thread, returning a JoinHandle for it.
func (JoinHandle) IsFinished ¶ added in v0.11.0
func (self JoinHandle) IsFinished() bool
Checks if the associated thread has finished running its main function.
func (JoinHandle) Join ¶ added in v0.11.0
func (self JoinHandle) Join() Result[Unit]
Waits for the associated thread to finish.
type LinkedList ¶ added in v0.5.0
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList is a doubly-linked list.
func LinkedListNew ¶ added in v0.5.0
func LinkedListNew[T any]() LinkedList[T]
Creates an empty LinkedList.
func (*LinkedList[T]) Append ¶ added in v0.5.0
func (list *LinkedList[T]) Append(other *LinkedList[T])
Moves all elements from other to the end of the list. This reuses all the nodes from other and moves them into self. After this operation, other becomes empty. This operation should compute in O(1) time and O(1) memory.
list1 := gost.LinkedListNew[gost.I32]() list1.PushBack(gost.I32(1)) list1.PushBack(gost.I32(2)) list1.PushBack(gost.I32(3)) list2 := gost.LinkedListNew[gost.I32]() list2.PushBack(gost.I32(4)) list2.PushBack(gost.I32(5)) list1.Append(&list2) gost.AssertEq(list1.Len(), gost.USize(5)) gost.AssertEq(list2.Len(), gost.USize(0))
func (LinkedList[T]) AsRef ¶ added in v0.7.3
func (self LinkedList[T]) AsRef() *LinkedList[T]
impl AsRef for LinkedList
func (*LinkedList[T]) Back ¶ added in v0.5.0
func (list *LinkedList[T]) Back() Option[*T]
Provides a reference to the back element, or None if the list is empty. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushBack(gost.I32(1)) list.PushBack(gost.I32(2)) gost.AssertEq(list.Back().Unwrap(), gost.I32(2))
func (*LinkedList[T]) Clear ¶ added in v0.5.0
func (list *LinkedList[T]) Clear()
Removes all elements from the LinkedList. This operation should compute in O(1) time. +GC
list := gost.LinkedListNew[gost.I32]() list.PushBack(gost.I32(1)) list.PushBack(gost.I32(2)) list.Clear() gost.Assert(list.IsEmpty())
func (LinkedList[T]) Clone ¶ added in v0.7.3
func (self LinkedList[T]) Clone() LinkedList[T]
impl Clone for LinkedList
func (LinkedList[T]) Debug ¶ added in v0.5.0
func (self LinkedList[T]) Debug() String
impl Debug for LinkedList
func (LinkedList[T]) Display ¶ added in v0.5.0
func (self LinkedList[T]) Display() String
impl Display for LinkedList
func (LinkedList[T]) Eq ¶ added in v0.7.3
func (self LinkedList[T]) Eq(rhs LinkedList[T]) Bool
impl Eq for LinkedList
func (*LinkedList[T]) Front ¶ added in v0.5.0
func (list *LinkedList[T]) Front() Option[*T]
Provides a reference to the front element, or None if the list is empty. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushFront(gost.I32(1)) list.PushFront(gost.I32(2)) gost.AssertEq(list.Front().Unwrap(), gost.I32(2))
func (*LinkedList[T]) IntoIter ¶ added in v0.5.0
func (list *LinkedList[T]) IntoIter() Iterator[T]
into_iter
func (LinkedList[T]) IsEmpty ¶ added in v0.5.0
func (list LinkedList[T]) IsEmpty() Bool
Returns true if the LinkedList is empty. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() gost.Assert(list.IsEmpty()) list.PushBack(gost.I32(1)) gost.Assert(!list.IsEmpty())
func (LinkedList[T]) Len ¶ added in v0.5.0
func (list LinkedList[T]) Len() USize
Returns the length of the LinkedList. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushBack(gost.I32(1)) list.PushBack(gost.I32(2)) gost.AssertEq(list.Len(), gost.USize(2))
func (*LinkedList[T]) PopBack ¶ added in v0.5.0
func (list *LinkedList[T]) PopBack() Option[T]
Removes the last element from a list and returns it, or None if it is empty. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushBack(gost.I32(1)) list.PushBack(gost.I32(2)) gost.AssertEq(list.PopBack().Unwrap(), gost.I32(2)) gost.AssertEq(list.PopBack().Unwrap(), gost.I32(1)) gost.Assert(list.PopBack().IsNone())
func (*LinkedList[T]) PopFront ¶ added in v0.5.0
func (list *LinkedList[T]) PopFront() Option[T]
Removes the first element and returns it, or None if the list is empty. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushFront(gost.I32(1)) list.PushFront(gost.I32(2)) gost.AssertEq(list.PopFront().Unwrap(), gost.I32(2)) gost.AssertEq(list.PopFront().Unwrap(), gost.I32(1))
func (*LinkedList[T]) PushBack ¶ added in v0.5.0
func (list *LinkedList[T]) PushBack(value T)
Appends an element to the back of a list. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushBack(gost.I32(1)) list.PushBack(gost.I32(2)) gost.AssertEq(list.Len(), gost.USize(2))
func (*LinkedList[T]) PushFront ¶ added in v0.5.0
func (list *LinkedList[T]) PushFront(value T)
Adds an element first in the list. This operation should compute in O(1) time.
list := gost.LinkedListNew[gost.I32]() list.PushFront(gost.I32(1)) list.PushFront(gost.I32(2)) gost.AssertEq(list.Len(), gost.USize(2))
type LinkedListIter ¶ added in v0.5.0
type LinkedListIter[T any] struct { // contains filtered or unexported fields }
linked list iterator
func (LinkedListIter[T]) CollectToLinkedList ¶ added in v0.6.0
func (self LinkedListIter[T]) CollectToLinkedList() LinkedList[T]
Collect To LinkedList
func (LinkedListIter[T]) CollectToVec ¶ added in v0.5.0
func (self LinkedListIter[T]) CollectToVec() Vec[T]
Collect To Vec
func (LinkedListIter[T]) Filter ¶ added in v0.5.0
func (self LinkedListIter[T]) Filter(f func(T) Bool) Iterator[T]
filter
func (LinkedListIter[T]) Fold ¶ added in v0.5.0
func (self LinkedListIter[T]) Fold(init T, f func(T, T) T) T
fold
func (LinkedListIter[T]) Map ¶ added in v0.5.0
func (self LinkedListIter[T]) Map(f func(T) T) Iterator[T]
map
func (*LinkedListIter[T]) Next ¶ added in v0.5.0
func (self *LinkedListIter[T]) Next() Option[T]
next
type LinkedListNode ¶ added in v0.5.0
type LinkedListNode[T any] struct { // contains filtered or unexported fields }
type Mul ¶
type Mul[T any] interface { Mul(rhs T) T }
Mul is a trait for types that support multiplication.
type MulAssign ¶
type MulAssign[T any] interface { MulAssign(rhs T) }
The multiplication assignment operator *=.
type Mutex ¶ added in v0.7.3
type Mutex[T any] struct { // contains filtered or unexported fields }
A mutual exclusion lock.
locker := MutexNew[ISize](0) ptr := locker.Lock() *ptr = 1 locker.Unlock()
func (*Mutex[T]) Lock ¶ added in v0.7.3
func (self *Mutex[T]) Lock() *T
Acquires a mutex, blocking the current thread until it is able to do so.
locker := MutexNew[ISize](0) ptr := locker.Lock() *ptr = 1
func (*Mutex[T]) TryLock ¶ added in v0.7.3
Attempts to acquire this lock. If the lock could not be acquired at this time, then Err is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.
locker := MutexNew[ISize](0) ptr := locker.TryLock() if ptr.IsErr() { panic("Mutex is locked") } *ptr.Unwrap() = 1
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not. Option types are very common in Rust code
func (Option[T]) And ¶
Returns None if the option is None, otherwise returns optb. Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use and_then, which is lazily evaluated.
x := Some(gost.I32(2)) y := None[gost.I32]() gost.AssertEq(x.and(y), None); x := Some(gost.I32(2)) y := Some(gost.I32(3)) gost.AssertEq(x.and(y), Some(gost.I32(3))); x := None[gost.I32]() y := None[gost.I32]() gost.AssertEq(x.and(y), None); x := Some(gost.I32(2)) y := Some(gost.I32(3)) gost.AssertEq(x.and(y), Some(gost.I32(3)));
func (Option[T]) AndThen ¶
Returns None if the option is None, otherwise calls f with the wrapped value and returns the result. Some languages call this operation flatmap.
x := Some(gost.I32(2)) gost.AssertEq(x.and_then(func(value gost.I32) Option[gost.I32] { return Some[gost.I32](value + 1) }), Some(gost.I32(3))) x := None[gost.I32]() gost.AssertEq(x.and_then(func(value gost.I32) Option[gost.I32] { return Some[gost.I32](value + 1) }), None[gost.I32]())
func (Option[T]) Expect ¶
Returns the contained Some value, consuming the self value.
x := Some(gost.I32(2)) gost.AssertEq(x.Expect(gost.String("failed")), gost.I32(2))
func (Option[T]) Filter ¶
Returns None if the option is None, otherwise calls predicate with the wrapped value and returns: 1. Some(t) if predicate returns true (where t is the wrapped value), and 2. None if predicate returns false.
x := Some(gost.I32(2)) gost.AssertEq(x.filter(func(value gost.I32) gost.Bool { return value == 2 }), Some(gost.I32(2)))
func (*Option[T]) GetOrInsert ¶
func (self *Option[T]) GetOrInsert(value T) *T
Inserts value into the option if it is None, then returns a mutable reference to the contained value. See also Option::insert, which updates the value even if the option already contains Some.
x := None[gost.I32]() gost.AssertEq(x.GetOrInsert(gost.I32(2)), Some(gost.I32(2))) x := Some(gost.I32(3)) gost.AssertEq(x.GetOrInsert(gost.I32(2)), Some(gost.I32(3)))
func (*Option[T]) GetOrInsertWith ¶
func (self *Option[T]) GetOrInsertWith(f func() T) *T
Inserts a value computed from f into the option if it is None, then returns a mutable reference to the contained value.
x := None[gost.I32]() gost.AssertEq(x.GetOrInsertWith(func() gost.I32 { return gost.I32(2) }), Some(gost.I32(2))) x := Some(gost.I32(3)) gost.AssertEq(x.GetOrInsertWith(func() gost.I32 { return gost.I32(2) }), Some(gost.I32(3)))
func (*Option[T]) Insert ¶
func (self *Option[T]) Insert(value T) *T
Inserts value into the option, then returns a mutable reference to it. If the option already contains a value, the old value is dropped. See also Option::get_or_insert, which doesn’t update the value if the option already contains Some.
x := None[gost.I32]() gost.AssertEq(x.Insert(gost.I32(2)), Some(gost.I32(2))) x := Some(gost.I32(3)) gost.AssertEq(x.Insert(gost.I32(2)), Some(gost.I32(2)))
func (Option[T]) IsNone ¶
Returns true if the option is a None value.
x := None[gost.I32]() gost.Assert(x.IsNone())
func (Option[T]) IsSome ¶
Returns true if the option is a Some value.
x := Some(gost.I32(2)) gost.Assert(x.IsSome())
func (*Option[T]) IsSomeAnd ¶
Returns true if the option is a Some and the value inside of it matches a predicate.
x := Some(gost.I32(2)) gost.Assert(x.IsSomeAnd(func(value gost.I32) gost.Bool { return value == 2 }))
func (Option[T]) Map ¶
Maps an Option<T> to other Option<T> by applying a function to a contained value (if Some) or returns None (if None).
x := Some(gost.I32(2)) gost.AssertEq(x.Map(func(value gost.I32) gost.I32 { return value + 1 }), Some(gost.I32(3))) x := None[gost.I32]() gost.AssertEq(x.Map(func(value gost.I32) gost.I32 { return value + 1 }), None[gost.I32]())
func (Option[T]) MapOr ¶
func (self Option[T]) MapOr(defaultValue T, f func(T) T) T
Returns the provided default result (if none), or applies a function to the contained value (if any). Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use map_or_else, which is lazily evaluated.
x := Some(gost.I32(2)) gost.AssertEq(x.MapOr(gost.I32(3), func(value gost.I32) gost.I32 { return value + 1 }), gost.I32(3)) x := None[gost.I32]() gost.AssertEq(x.MapOr(gost.I32(3), func(value gost.I32) gost.I32 { return value + 1 }), gost.I32(3))
func (Option[T]) MapOrElse ¶
func (self Option[T]) MapOrElse(defaultValue func() T, f func(T) T) T
Computes a default function result (if none), or applies a different function to the contained value (if any).
x := Some(gost.I32(2)) gost.AssertEq(x.MapOrElse(func() gost.I32 { return gost.I32(3) }, func(value gost.I32) gost.I32 { return value + 1 }), gost.I32(3))
func (Option[T]) Or ¶
Returns the option if it contains a value, otherwise returns optb. Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use or_else, which is lazily evaluated.
x := Some(gost.I32(2)) y := None[gost.I32]() gost.AssertEq(x.or(y), Some(gost.I32(2))); x := Some(gost.I32(2)) y := Some(gost.I32(3)) gost.AssertEq(x.or(y), Some(gost.I32(2)));
func (Option[T]) OrElse ¶
Returns the option if it contains a value, otherwise calls f and returns the result.
x := Some(gost.I32(2)) gost.AssertEq(x.or_else(func() Option[gost.I32] { return Some[gost.I32](3) }), Some(gost.I32(2))) x := None[gost.I32]() gost.AssertEq(x.or_else(func() Option[gost.I32] { return Some[gost.I32](3) }), Some(gost.I32(3)))
func (*Option[T]) Replace ¶
Replaces the actual value in the option by the value given in parameter, returning the old value if present, leaving a Some in its place without deinitializing either one.
x := Some(gost.I32(2)) gost.AssertEq(x.Replace(gost.I32(3)), Some(gost.I32(2))) x := None[gost.I32]() gost.AssertEq(x.Replace(gost.I32(3)), None[gost.I32]())
func (*Option[T]) Take ¶
Takes the value out of the option, leaving a None in its place.
x := Some(gost.I32(2)) gost.AssertEq(x.Take(), Some(gost.I32(2))) x := None[gost.I32]() gost.AssertEq(x.Take(), None[gost.I32]())
func (Option[T]) Unwrap ¶
func (self Option[T]) Unwrap() T
Returns the contained Some value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the None case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.
x := Some(gost.I32(2)) gost.AssertEq(x.Unwrap(), gost.I32(2))
func (Option[T]) UnwrapOr ¶
func (self Option[T]) UnwrapOr(value T) T
Returns the contained Some value or a provided default. Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.
x := Some(gost.I32(2)) gost.AssertEq(x.UnwrapOr(gost.I32(3)), gost.I32(2)) x := None[gost.I32]() gost.AssertEq(x.UnwrapOr(gost.I32(3)), gost.I32(3))
func (Option[T]) UnwrapOrElse ¶
func (self Option[T]) UnwrapOrElse(f func() T) T
Returns the contained Some value or computes it from a closure.
x := Some(gost.I32(2)) gost.AssertEq(x.UnwrapOrElse(func() gost.I32 { return gost.I32(3) }), gost.I32(2))
type Pair ¶
Pair is a tuple of two values.
type Rem ¶ added in v0.9.0
type Rem[T any] interface { Rem(rhs T) T }
Rem is a trait for types that support remainder after division.
type RemAssign ¶ added in v0.9.0
type RemAssign[T any] interface { RemAssign(rhs T) }
The remainder assignment operator %=.
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
Error handling with the Result type. Result<T> is the type used for returning and propagating errors. It is an enum with the variants, Ok(T), representing success and containing a value, and Err, representing error and containing an error value.
func Copy ¶
Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file. This function will overwrite the contents of to.
func ReadToString ¶
Read the entire contents of a file into a string.
func Rename ¶
Rename a file or directory to a new name, replacing the original file if to already exists. This will not work if the new name is on a different mount point.
func StringFromUTF16 ¶ added in v0.10.0
Decode a UTF-16–encoded vector v into a String, returning Err if v contains any invalid data.
func (Result[T]) And ¶
Returns res if the result is Ok, otherwise returns the Err value of self. Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use and_then, which is lazily evaluated.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.And(gost.Ok[gost.I32](gost.I32(3))), gost.Ok[gost.I32](gost.I32(3))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.And(gost.Ok[gost.I32](gost.I32(3))), gost.Err[gost.I32](errors.New("error")))
func (Result[T]) AndThen ¶
Calls op if the result is Ok, otherwise returns the Err value of self. This function can be used for control flow based on Result values.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.AndThen(func(value Int) Result[Int] { return gost.Ok[Int](value + 1) }), gost.Ok[gost.I32](gost.I32(3))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.AndThen(func(value Int) Result[Int] { return gost.Ok[Int](value + 1) }), gost.Err[gost.I32](errors.New("error")))
func (Result[T]) Err ¶
Converts from Result<T, E> to Option<E>. Converts self into an Option<E>, consuming self, and discarding the success value, if any.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Err(), gost.None[error]()) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.Err(), gost.Some[error](errors.New("error")))
func (Result[T]) Expect ¶
Returns the contained Ok value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the Err case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Expect("error"), gost.I32(2))
func (Result[T]) ExpectErr ¶
Returns the contained Err value, consuming the self value.
x := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(x.ExpectErr("error"), errors.New("error"))
func (Result[T]) IsErr ¶
Returns true if the result is Err.
x := gost.Ok[gost.I32](gost.I32(2)) gost.Assert(!x.IsErr()) y := gost.Err[gost.I32](errors.New("error")) gost.Assert(y.IsErr())
func (Result[T]) IsErrAnd ¶
Returns true if the result is Err and the value inside of it matches a predicate.
x := gost.Err[gost.I32](errors.New("error")) gost.Assert(x.IsErrAnd(func(err error) Bool { return err.Error() == "error" })) y := gost.Err[gost.I32](errors.New("error")) gost.Assert(!y.IsErrAnd(func(err error) Bool { return err.Error() == "error2" }))
func (Result[T]) IsOk ¶
Returns true if the result is Ok.
x := gost.Ok[gost.I32](gost.I32(2)) gost.Assert(x.IsOk()) y := gost.Err[gost.I32](errors.New("error")) gost.Assert(!y.IsOk())
func (Result[T]) IsOkAnd ¶
Returns true if the result is Ok and the value inside of it matches a predicate.
x := gost.Ok[gost.I32](gost.I32(2)) gost.Assert(x.IsOkAnd(func(value Int) Bool { return value == 2 })) y := gost.Ok[gost.I32](gost.I32(3)) gost.Assert(!y.IsOkAnd(func(value Int) Bool { return value == 2 }))
func (Result[T]) Map ¶
Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched. This function can be used to compose the results of two functions.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Map(func(value Int) Int { return value + 1 }), gost.Ok[gost.I32](gost.I32(3))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.Map(func(value Int) Int { return value + 1 }), gost.Err[gost.I32](errors.New("error")))
func (Result[T]) MapErr ¶
Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched. This function can be used to pass through a successful result while handling an error.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.MapErr(func(err error) error { return errors.New("error2") }), gost.Ok[gost.I32](gost.I32(2))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.MapErr(func(err error) error { return errors.New("error2") }), gost.Err[gost.I32](errors.New("error2")))
func (Result[T]) MapOr ¶
func (self Result[T]) MapOr(defaultValue T, f func(T) T) T
Returns the provided default (if Err), or applies a function to the contained value (if Ok), Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use map_or_else, which is lazily evaluated.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.MapOr(gost.I32(3), func(value Int) Int { return value + 1 }), gost.I32(3)) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.MapOr(gost.I32(3), func(value Int) Int { return value + 1 }), gost.I32(3))
func (Result[T]) MapOrElse ¶
func (self Result[T]) MapOrElse(defaultValue func() T, f func(T) T) T
Maps a Result<T, E> to U by applying fallback function default to a contained Err value, or function f to a contained Ok value. This function can be used to unpack a successful result while handling an error.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.MapOrElse(func() Int { return gost.I32(3) }, func(value Int) Int { return value + 1 }), gost.I32(3)) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.MapOrElse(func() Int { return gost.I32(3) }, func(value Int) Int { return value + 1 }), gost.I32(3))
func (Result[T]) Ok ¶
Converts from Result<T, E> to Option<T>. Converts self into an Option<T>, consuming self, and discarding the error, if any.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Ok(), gost.Some[gost.I32](gost.I32(2))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.Ok(), gost.None[gost.I32]())
func (Result[T]) Or ¶
Returns res if the result is Err, otherwise returns the Ok value of self. Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use or_else, which is lazily evaluated.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Or(gost.Ok[gost.I32](gost.I32(3))), gost.Ok[gost.I32](gost.I32(2))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.Or(gost.Ok[gost.I32](gost.I32(3))), gost.Ok[gost.I32](gost.I32(3)))
func (Result[T]) OrElse ¶
Calls op if the result is Err, otherwise returns the Ok value of self. This function can be used for control flow based on result values.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.OrElse(func(err error) Result[Int] { return gost.Ok[Int](gost.I32(3)) }), gost.Ok[gost.I32](gost.I32(2))) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.OrElse(func(err error) Result[Int] { return gost.Ok[Int](gost.I32(3)) }), gost.Ok[gost.I32](gost.I32(3)))
func (Result[T]) Unwrap ¶
func (self Result[T]) Unwrap() T
Returns the contained Ok value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the Err case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.Unwrap(), gost.I32(2))
func (Result[T]) UnwrapErr ¶
Returns the contained Err value, consuming the self value.
x := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(x.UnwrapErr(), errors.New("error"))
func (Result[T]) UnwrapOr ¶
func (self Result[T]) UnwrapOr(defaultValue T) T
Returns the contained Ok value or a provided default. Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.UnwrapOr(gost.I32(3)), gost.I32(2)) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.UnwrapOr(gost.I32(3)), gost.I32(3))
func (Result[T]) UnwrapOrElse ¶
func (self Result[T]) UnwrapOrElse(f func() T) T
Returns the contained Ok value or computes it from a closure.
x := gost.Ok[gost.I32](gost.I32(2)) gost.AssertEq(x.UnwrapOrElse(func() Int { return gost.I32(3) }), gost.I32(2)) y := gost.Err[gost.I32](errors.New("error")) gost.AssertEq(y.UnwrapOrElse(func() Int { return gost.I32(3) }), gost.I32(3))
type Stdin ¶
type Stdin struct {
// contains filtered or unexported fields
}
type String ¶
type String string
func StringFromUTF8 ¶ added in v0.10.0
Converts a vector of bytes to a String.
func (String) Contains ¶ added in v0.10.0
Returns true if the given pattern matches a sub-slice of this string slice. Returns false if it does not. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
func (String) Find ¶ added in v0.10.0
Returns the byte index of the first character of this string slice that matches the pattern. Returns None if the pattern doesn’t match. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
func (String) IntoBytes ¶ added in v0.10.0
Converts a String into a byte vector. This consumes the String, so we do not need to copy its contents.
func (String) IsEmpty ¶ added in v0.10.0
Returns true if this String has a length of zero, and false otherwise.
func (String) Len ¶ added in v0.10.0
Returns the length of this String, in bytes, not chars or graphemes. In other words, it might not be what a human considers the length of the string.
func (*String) Pop ¶ added in v0.10.0
Removes the last character from the string buffer and returns it. Returns None if this String is empty.
func (String) Replace ¶ added in v0.10.0
Replaces all matches of a pattern with another string. replace creates a new String, and copies the data from this string slice into it. While doing so, it attempts to find matches of a pattern. If it finds any, it replaces them with the replacement string slice.
func (String) Split ¶ added in v0.10.0
An iterator over substrings of this string slice, separated by characters matched by a string
func (String) ToLowercase ¶ added in v0.10.0
Returns the lowercase equivalent of this string slice, as a new String.
func (String) ToUppercase ¶ added in v0.10.0
Returns the uppercase equivalent of this string slice, as a new String.
type Sub ¶
type Sub[T any] interface { Sub(rhs T) T }
Sub is a trait for types that support subtraction.
type SubAssign ¶
type SubAssign[T any] interface { SubAssign(rhs T) }
The subtraction assignment operator -=.
type TryLockError ¶ added in v0.7.3
type TryLockError struct{}
An error returned by TryLock.
func (TryLockError) Error ¶ added in v0.7.3
func (self TryLockError) Error() string
type U128 ¶ added in v0.11.0
type U128 struct {
// contains filtered or unexported fields
}
func U128_FromU64 ¶ added in v0.11.0
type U16 ¶ added in v0.6.0
type U16 uint16
func (U16) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (U16) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (U16) SaturatingAdd ¶ added in v0.10.0
func (U16) SaturatingDiv ¶ added in v0.10.0
func (U16) SaturatingMul ¶ added in v0.10.0
func (U16) SaturatingSub ¶ added in v0.9.0
func (U16) WrappingAdd ¶ added in v0.8.0
func (U16) WrappingDiv ¶ added in v0.9.0
func (U16) WrappingMul ¶ added in v0.9.0
func (U16) WrappingSub ¶ added in v0.8.0
type U32 ¶ added in v0.6.0
type U32 uint32
func (U32) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (U32) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (U32) SaturatingAdd ¶ added in v0.10.0
func (U32) SaturatingDiv ¶ added in v0.10.0
func (U32) SaturatingMul ¶ added in v0.10.0
func (U32) SaturatingSub ¶ added in v0.9.0
func (U32) WrappingAdd ¶ added in v0.8.0
func (U32) WrappingDiv ¶ added in v0.9.0
func (U32) WrappingMul ¶ added in v0.9.0
func (U32) WrappingSub ¶ added in v0.8.0
type U64 ¶ added in v0.6.0
type U64 uint64
func (U64) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (U64) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (U64) SaturatingAdd ¶ added in v0.10.0
func (U64) SaturatingDiv ¶ added in v0.10.0
func (U64) SaturatingMul ¶ added in v0.10.0
func (U64) SaturatingSub ¶ added in v0.9.0
func (U64) WrappingAdd ¶ added in v0.8.0
func (U64) WrappingDiv ¶ added in v0.9.0
func (U64) WrappingMul ¶ added in v0.9.0
func (U64) WrappingSub ¶ added in v0.8.0
type U8 ¶ added in v0.6.0
type U8 uint8
func (U8) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (U8) SaturatingAdd ¶ added in v0.10.0
func (U8) SaturatingDiv ¶ added in v0.10.0
func (U8) SaturatingMul ¶ added in v0.10.0
func (U8) SaturatingSub ¶ added in v0.9.0
func (U8) WrappingAdd ¶ added in v0.8.0
func (U8) WrappingDiv ¶ added in v0.9.0
func (U8) WrappingMul ¶ added in v0.9.0
func (U8) WrappingSub ¶ added in v0.8.0
type USize ¶ added in v0.6.0
type USize uint
func (USize) AbsDiff ¶ added in v0.10.0
Computes the absolute difference between self and other. This function always returns the correct answer without overflow or panics by returning an unsigned integer.
func (USize) Pow ¶ added in v0.10.0
Raises self to the power of exp, using exponentiation by squaring.
func (USize) SaturatingAdd ¶ added in v0.10.0
func (USize) SaturatingDiv ¶ added in v0.10.0
func (USize) SaturatingMul ¶ added in v0.10.0
func (USize) SaturatingSub ¶ added in v0.9.0
func (USize) WrappingAdd ¶ added in v0.8.0
func (USize) WrappingDiv ¶ added in v0.9.0
func (USize) WrappingMul ¶ added in v0.9.0
func (USize) WrappingSub ¶ added in v0.8.0
type Vec ¶
type Vec[T any] struct { // contains filtered or unexported fields }
A contiguous growable array type with heap-allocated contents, written Vec<T>. Vectors have O(1) indexing, amortized O(1) push (to the end) and O(1) pop (from the end).
func VecNew ¶
Constructs a new, empty Vec<T>. The vector will not allocate until elements are pushed onto it.
func VecWithCapacity ¶
Constructs a new, empty Vec<T> with at least the specified capacity.
func VecWithLen ¶
Constructs a new, empty Vec<T> with at least the specified len.
func (*Vec[T]) Append ¶
Moves all the elements of other ISizeo self, leaving other empty.
vec1 := gost.VecNew[gost.I32]() vec2 := gost.VecNew[gost.I32]() vec1.Push(1) vec2.Push(2) vec1.Append(&vec2) gost.AssertEq(vec1.Len(), gost.USize(2))
func (Vec[T]) AsSlice ¶
func (self Vec[T]) AsSlice() []T
Extracts a slice containing the entire vector.
func (Vec[T]) BinarySearch ¶
Binary searches this slice for a given element. If the slice is not sorted, the returned result is unspecified and meaningless.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.Assert(vec.BinarySearch(2).IsSome()) gost.Assert(vec.BinarySearch(4).IsNone())
func (Vec[T]) BinarySearchBy ¶
Binary searches this slice with a comparator function. The comparator function should return an order code that indicates whether its argument is Less, Equal or Greater the desired target. If the slice is not sorted or if the comparator function does not implement an order consistent with the sort order of the underlying slice, the returned result is unspecified and meaningless.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.Assert(vec.BinarySearchBy(func(e gost.I32) gost.Ordering { if e < 2 { return gost.OrderingLess } else if e > 2 { return gost.OrderingGreater } else { return gost.OrderingEqual } }).IsSome())
func (Vec[T]) Capacity ¶
Returns the total number of elements the vector can hold without reallocating.
vec := gost.VecNew[gost.I32]() gost.AssertEq(vec.Capacity(), gost.USize(0)) vec.Reserve(10) gost.AssertEq(vec.Capacity(), gost.USize(10))
func (*Vec[T]) Clear ¶
func (self *Vec[T]) Clear()
Clears the vector, removing all values.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Clear() gost.AssertEq(vec.Len(), gost.USize(0))
func (Vec[T]) Contains ¶
Returns true if the slice contains an element with the given value. This operation is O(n). Note that if you have a sorted slice, binary_search may be faster.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.Assert(vec.Contains(2)) gost.Assert(!vec.Contains(4))
func (*Vec[T]) Dedup ¶
func (self *Vec[T]) Dedup()
Removes consecutive repeated elements in the vector according to the PartialEq trait implementation. If the vector is sorted, this removes all duplicates.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(2) vec.Push(3) vec.Dedup() gost.AssertEq(vec.Len(), gost.USize(3))
func (*Vec[T]) DedupByKey ¶
Removes all but the first of consecutive elements in the vector that resolve to the same key. If the vector is sorted, this removes all duplicates.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(2) vec.Push(3) vec.DedupByKey(func(e gost.I32) gost.I32 { return e } gost.AssertEq(vec.Len(), gost.USize(3))
func (*Vec[T]) Fill ¶
func (self *Vec[T]) Fill(value T)
Fills self with elements by cloning value.
vec := gost.VecWithLen[gost.I32](gost.USize(5)) vec.Fill(gost.I32(1)) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) FillWith ¶
func (self *Vec[T]) FillWith(f func() T)
Fills self with elements returned by calling a closure repeatedly.
vec := gost.VecWithLen[gost.I32](gost.USize(5)) vec.FillWith(func() gost.I32 { return 1 }) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (Vec[T]) Get ¶
Returns a reference to an element or subslice depending on the type of index. If given a position, returns a reference to the element at that position or None if out of bounds. If given a range, returns the subslice corresponding to that range, or None if out of bounds.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.AssertEq(vec.Get(0).Unwrap(), gost.I32(1)) gost.AssertEq(vec.Get(1).Unwrap(), gost.I32(2))
func (Vec[T]) GetUnchecked ¶
Returns a reference to an element or subslice, without doing bounds checking. For a safe alternative see get.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) Insert ¶
Inserts an element at position index within the vector, shifting all elements after it to the right.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Insert(1, 3) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1)) gost.AssertEq(vec.GetUnchecked(1), gost.I32(3))
func (Vec[T]) IsEmpty ¶
Returns true if the vector contains no elements.
vec := gost.VecNew[gost.I32]() gost.Assert(vec.IsEmpty()) vec.Push(1) gost.Assert(!vec.IsEmpty())
func (Vec[T]) Len ¶
Returns the number of elements in the vector, also referred to as its ‘length’.
vec := gost.VecNew[gost.I32]() gost.AssertEq(vec.Len(), gost.USize(0)) vec.Push(1) gost.AssertEq(vec.Len(), gost.USize(1))
func (*Vec[T]) Pop ¶
Removes the last element from a vector and returns it, or None if it is empty.
vec := gost.VecNew[gost.I32]() gost.AssertEq(vec.Pop().IsNone(), true) vec.Push(1) gost.AssertEq(vec.Pop().IsSome(), true)
func (*Vec[T]) Push ¶
func (self *Vec[T]) Push(value T)
Appends an element to the back of a collection.
vec := gost.VecNew[gost.I32]() gost.AssertEq(vec.Len(), gost.USize(0)) vec.Push(1) gost.AssertEq(vec.Len(), gost.USize(1))
func (*Vec[T]) Reserve ¶
Reserves capacity for at least additional more elements to be inserted in the given Vec<T>. The collection may reserve more space to speculatively avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
vec := gost.VecNew[gost.I32]() gost.AssertEq(vec.Capacity(), gost.USize(0)) vec.Reserve(10) gost.AssertEq(vec.Capacity(), gost.USize(10))
func (*Vec[T]) Retain ¶
Retains only the elements specified by the predicate. In other words, remove all elements e such that f(e) returns false. This method operates in place and preserves the order of the retained elements.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) vec.Retain(func(e gost.I32) gost.Bool { return e == 2 }) gost.AssertEq(vec.Len(), gost.USize(1))
func (*Vec[T]) Reverse ¶
func (self *Vec[T]) Reverse()
Reverses the order of elements in the slice, in place.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) vec.Reverse() gost.AssertEq(vec.GetUnchecked(0), gost.I32(3))
func (*Vec[T]) Set ¶ added in v0.7.0
Set value
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) vec.Set(0, 4) gost.AssertEq(vec.GetUnchecked(0), gost.I32(4))
func (*Vec[T]) SetUnchecked ¶ added in v0.7.0
Set unchecked
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) vec.SetUnchecked(0, 4) gost.AssertEq(vec.GetUnchecked(0), gost.I32(4))
func (*Vec[T]) Sort ¶
func (self *Vec[T]) Sort()
Sorts the slice. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn’t allocate auxiliary memory. See sort_unstable.
vec := gost.VecNew[gost.I32]() vec.Push(3) vec.Push(2) vec.Push(1) vec.Sort() gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) SortBy ¶
Sorts the slice with a comparator function. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.
vec := gost.VecNew[gost.I32]() vec.Push(3) vec.Push(2) vec.Push(1) vec.SortBy(func(lhs, rhs gost.I32) gost.Ordering { if lhs < rhs { return gost.OrderingLess } else if lhs > rhs { return gost.OrderingGreater } else { return gost.OrderingEqual } }) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) SortUnstable ¶
func (self *Vec[T]) SortUnstable()
Sorts the slice, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case.
vec := gost.VecNew[gost.I32]() vec.Push(3) vec.Push(2) vec.Push(1) vec.SortUnstable() gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) SortUnstableBy ¶
Sorts the slice with a comparator function, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.
vec := gost.VecNew[gost.I32]() vec.Push(3) vec.Push(2) vec.Push(1) vec.SortUnstableBy(func(lhs, rhs gost.I32) gost.Ordering { if lhs < rhs { return gost.OrderingLess } else if lhs > rhs { return gost.OrderingGreater } else { return gost.OrderingEqual } }) gost.AssertEq(vec.GetUnchecked(0), gost.I32(1))
func (*Vec[T]) Swap ¶
Swaps two elements in the slice. If a equals to b, it’s guaranteed that elements won’t change value.
vec := gost.VecNew[gost.I32]() vec.Push(1) vec.Push(2) vec.Push(3) vec.Swap(0, 2) gost.AssertEq(vec.GetUnchecked(0), gost.I32(3)) gost.AssertEq(vec.GetUnchecked(2), gost.I32(1))
type VecDeque ¶ added in v0.8.0
type VecDeque[T any] struct { // contains filtered or unexported fields }
A double-ended queue implemented with a growable ring buffer.
func VecDequeWithCapacity ¶ added in v0.8.0
Creates an empty VecDeque with at least the specified capacity.
func VecDequeWithLen ¶ added in v0.9.0
Constructs a new, empty Vec<T> with at least the specified capacity.
func (*VecDeque[T]) Append ¶ added in v0.9.0
Moves all the elements of other ISizeo self, leaving other empty.
deque1 := gost.VecDequeNew[gost.I32]() deque2 := gost.VecDequeNew[gost.I32]() deque1.PushBack(1) deque2.PushBack(2) deque1.Append(&deque2) gost.AssertEq(deque1.Len(), gost.USize(2)) gost.AssertEq(deque2.Len(), gost.USize(0))
func (VecDeque[T]) AsSlice ¶ added in v0.9.0
func (self VecDeque[T]) AsSlice() []T
Extracts a slice containing the entire vecdeque.
func (VecDeque[T]) Back ¶ added in v0.8.0
Provides a reference to the back element, or None if the deque is empty.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Back(), gost.Some[gost.I32](gost.I32(4)))
func (VecDeque[T]) BinarySearch ¶ added in v0.9.0
Binary searches this slice for a given element. If the slice is not sorted, the returned result is unspecified and meaningless.
deque := gost.VecDequeNew[gost.I32]() deque.Push(1) deque.Push(2) deque.Push(3) gost.Assert(deque.BinarySearch(2).IsSome()) gost.Assert(deque.BinarySearch(4).IsNone())
func (VecDeque[T]) BinarySearchBy ¶ added in v0.9.0
Binary searches this slice with a comparator function. The comparator function should return an order code that indicates whether its argument is Less, Equal or Greater the desired target. If the slice is not sorted or if the comparator function does not implement an order consistent with the sort order of the underlying slice, the returned result is unspecified and meaningless.
deque := gost.VecDequeNew[gost.I32]() deque.Push(1) deque.Push(2) deque.Push(3) gost.Assert(deque.BinarySearchBy(func(e gost.I32) gost.Ordering { if e < 2 { return gost.OrderingLess } else if e > 2 { return gost.OrderingGreater } else { return gost.OrderingEqual } }).IsSome())
func (VecDeque[T]) Capacity ¶ added in v0.8.0
Returns the number of elements the deque can hold without reallocating.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) deque.Reserve(gost.USize(8)) gost.AssertEqual(deque.Capacity(), gost.USize(8)) gost.AssertEqual(deque.Len(), gost.USize(2))
func (*VecDeque[T]) Clear ¶ added in v0.8.0
func (self *VecDeque[T]) Clear()
Clears the deque, removing all values.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) deque.Clear() gost.AssertEqual(deque.Len(), gost.USize(0))
func (VecDeque[T]) Contains ¶ added in v0.8.0
Require `impl Eq[T] for T` Returns true if the deque contains an element equal to the given value. This operation is O(n). Note that if you have a sorted VecDeque, binary_search may be faster.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Contains(gost.I32(3)), gost.Bool(true)) gost.AssertEqual(deque.Contains(gost.I32(4)), gost.Bool(true)) gost.AssertEqual(deque.Contains(gost.I32(5)), gost.Bool(false))
func (*VecDeque[T]) Dedup ¶ added in v0.9.0
Removes consecutive repeated elements in the vector according to the PartialEq trait implementation. If the vecdeque is sorted, this removes all duplicates.
deque := gost.VecDequeNew[gost.I32]() deque.Push(1) deque.Push(2) deque.Push(2) deque.Push(3) deque.Dedup() gost.AssertEq(deque.Len(), gost.USize(3))
func (*VecDeque[T]) Fill ¶ added in v0.9.0
func (self *VecDeque[T]) Fill(value T)
Fills self with elements by cloning value.
deque := gost.VecDequeWithLen[gost.I32](gost.USize(5)) deque.Fill(gost.I32(1)) gost.AssertEq(deque.GetUnchecked(0), gost.I32(1)) gost.AssertEq(deque.GetUnchecked(1), gost.I32(1))
func (*VecDeque[T]) FillWith ¶ added in v0.9.0
func (self *VecDeque[T]) FillWith(f func() T)
Fills self with elements returned by calling a closure repeatedly.
deque := gost.VecDequeWithLen[gost.I32](gost.USize(5)) deque.FillWith(func() gost.I32 { return 1 }) gost.AssertEq(deque.GetUnchecked(0), gost.I32(1)) gost.AssertEq(deque.GetUnchecked(1), gost.I32(1))
func (VecDeque[T]) Front ¶ added in v0.8.0
Provides a reference to the front element, or None if the deque is empty.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Front(), gost.Some[gost.I32](gost.I32(3)))
func (VecDeque[T]) Get ¶ added in v0.8.0
Provides a reference to the element at the given index. Element at index 0 is the front of the queue.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Get(gost.USize(0)), gost.Some[gost.I32](gost.I32(3)))
func (VecDeque[T]) GetUnchecked ¶ added in v0.9.0
Returns a reference to an element or subslice, without doing bounds checking. For a safe alternative see get.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.GetUnchecked(gost.USize(0)), gost.I32(3))
func (VecDeque[T]) IsEmpty ¶ added in v0.8.0
Returns true if the deque is empty.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.IsEmpty(), gost.Bool(false))
func (VecDeque[T]) Len ¶ added in v0.8.0
Returns the number of elements in the vecdeque, also referred to as its ‘length’.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Len(), gost.USize(2))
func (*VecDeque[T]) PopBack ¶ added in v0.8.0
Removes the last element from the deque and returns it, or `None` if it is empty.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.PopBack(), gost.Some[gost.I32](gost.I32(4))) gost.AssertEqual(deque.PopBack(), gost.Some[gost.I32](gost.I32(3))) gost.AssertEqual(deque.PopBack(), gost.None[gost.I32]())
func (*VecDeque[T]) PopFront ¶ added in v0.8.0
Removes the first element and returns it, or `None` if the deque is empty.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.PopFront(), gost.Some[gost.I32](gost.I32(3))) gost.AssertEqual(deque.PopFront(), gost.Some[gost.I32](gost.I32(4))) gost.AssertEqual(deque.PopFront(), gost.None[gost.I32]())
func (*VecDeque[T]) PushBack ¶ added in v0.8.0
func (self *VecDeque[T]) PushBack(value T)
Appends an element to the back of the deque.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) gost.AssertEqual(deque.Len(), gost.USize(2))
func (*VecDeque[T]) PushFront ¶ added in v0.8.0
func (self *VecDeque[T]) PushFront(value T)
Prepends an element to the deque.
deque := gost.VecDequeNew[gost.I32]() deque.PushFront(gost.I32(3)) deque.PushFront(gost.I32(4)) gost.AssertEqual(deque.Len(), gost.USize(2))
func (*VecDeque[T]) Reserve ¶ added in v0.8.0
Reserves capacity for at least additional more elements to be inserted in the given deque. The collection may reserve more space to speculatively avoid frequent reallocations.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.PushBack(gost.I32(4)) deque.Reserve(gost.USize(8)) gost.AssertEqual(deque.Capacity(), gost.USize(8))
func (*VecDeque[T]) Retain ¶ added in v0.9.0
Retains only the elements specified by the predicate. In other words, remove all elements e such that f(e) returns false. This method operates in place and preserves the order of the retained elements.
deque := gost.VecDequeNew[gost.I32]() deque.Push(1) deque.Push(2) deque.Push(3) deque.Retain(func(e gost.I32) gost.Bool { return e == 2 })
func (*VecDeque[T]) Set ¶ added in v0.9.0
Set value at index.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.Set(gost.USize(0), gost.I32(4)) gost.AssertEqual(deque.Get(gost.USize(0)), gost.Some[gost.I32](gost.I32(4)))
func (*VecDeque[T]) SetUnchecked ¶ added in v0.9.0
Set value at index, without doing bounds checking.
deque := gost.VecDequeNew[gost.I32]() deque.PushBack(gost.I32(3)) deque.SetUnchecked(gost.USize(0), gost.I32(4)) gost.AssertEqual(deque.Get(gost.USize(0)), gost.Some[gost.I32](gost.I32(4)))
func (*VecDeque[T]) Sort ¶ added in v0.9.0
func (self *VecDeque[T]) Sort()
Sorts the slice. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn’t allocate auxiliary memory. See sort_unstable.
deque := gost.VecDequeNew[gost.I32]() deque.Push(3) deque.Push(2) deque.Push(1) deque.Sort() gost.AssertEq(deque.GetUnchecked(0), gost.I32(1)) gost.AssertEq(deque.GetUnchecked(1), gost.I32(2)) gost.AssertEq(deque.GetUnchecked(2), gost.I32(3))
func (*VecDeque[T]) SortBy ¶ added in v0.9.0
Sorts the slice with a comparator function. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.
deque := gost.VecDequeNew[gost.I32]() deque.Push(3) deque.Push(2) deque.Push(1) deque.SortBy(func(lhs, rhs gost.I32) gost.Ordering { if lhs < rhs { return gost.OrderingLess } else if lhs > rhs { return gost.OrderingGreater } else { return gost.OrderingEqual } }) gost.AssertEq(deque.GetUnchecked(0), gost.I32(1))
func (*VecDeque[T]) SortUnstable ¶ added in v0.9.0
func (self *VecDeque[T]) SortUnstable()
Sorts the slice, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case.
deque := gost.VecDequeNew[gost.I32]() deque.Push(3) deque.Push(2) deque.Push(1) deque.SortUnstable() gost.AssertEq(deque.GetUnchecked(0), gost.I32(1))
func (*VecDeque[T]) SortUnstableBy ¶ added in v0.9.0
Sorts the slice with a comparator function, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.
deque := gost.VecDequeNew[gost.I32]() deque.Push(3) deque.Push(2) deque.Push(1) deque.SortUnstableBy(func(lhs, rhs gost.I32) gost.Ordering { if lhs < rhs { return gost.OrderingLess } else if lhs > rhs { return gost.OrderingGreater } else { return gost.OrderingEqual } }) gost.AssertEq(deque.GetUnchecked(0), gost.I32(1))
func (*VecDeque[T]) Swap ¶ added in v0.9.0
Swaps two elements in the slice. if a equals to b, it’s guaranteed that elements won’t change value.
deque := gost.VecDequeNew[gost.I32]() deque.Push(1) deque.Push(2) deque.Push(3) deque.Swap(0, 2) gost.AssertEq(deque.GetUnchecked(0), gost.I32(3)) gost.AssertEq(deque.GetUnchecked(2), gost.I32(1))
type VecDequeIter ¶ added in v0.8.0
type VecDequeIter[T any] struct { // contains filtered or unexported fields }
iterator for VecDeque
func (*VecDequeIter[T]) CollectToLinkedList ¶ added in v0.8.0
func (self *VecDequeIter[T]) CollectToLinkedList() LinkedList[T]
collect to LinkedList
func (*VecDequeIter[T]) CollectToVec ¶ added in v0.8.0
func (self *VecDequeIter[T]) CollectToVec() Vec[T]
collect to Vec
func (*VecDequeIter[T]) Filter ¶ added in v0.8.0
func (self *VecDequeIter[T]) Filter(f func(T) Bool) Iterator[T]
filter
func (*VecDequeIter[T]) Fold ¶ added in v0.8.0
func (self *VecDequeIter[T]) Fold(initial T, f func(T, T) T) T
fold
func (*VecDequeIter[T]) Map ¶ added in v0.8.0
func (self *VecDequeIter[T]) Map(f func(T) T) Iterator[T]
map
type VecIter ¶
type VecIter[T any] struct { // contains filtered or unexported fields }
iterator for Vec
func (VecIter[T]) CollectToLinkedList ¶ added in v0.6.0
func (self VecIter[T]) CollectToLinkedList() LinkedList[T]
collect to LinkedList
Source Files ¶
- binary_heap.go
- bitwise.go
- btree_map.go
- btree_set.go
- clone.go
- cmp.go
- const.go
- convert.go
- default.go
- float.go
- fmt.go
- fs.go
- future.go
- hash_map.go
- hash_set.go
- io.go
- iter.go
- linked_list.go
- ops.go
- option.go
- pair.go
- panic.go
- primitive.go
- result.go
- string.go
- sync.go
- syntax.go
- thread.go
- time.go
- to_string.go
- utils.go
- vec.go
- vec_deque.go