Documentation
¶
Overview ¶
https://github.com/tidwall/btype
Copyright 2026 Joshua J Baker. All rights reserved. Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
btype - B-tree based collections for go
Index ¶
- func CompareFor[T any]() func(T, T) int
- type Array
- func (b *Array[T]) All() iter.Seq[T]
- func (b *Array[T]) Append(items ...T)
- func (b *Array[T]) Ascend(index int) iter.Seq[T]
- func (b *Array[T]) Back() (T, bool)
- func (b *Array[T]) Backward() iter.Seq[T]
- func (b *Array[T]) Clear()
- func (b *Array[T]) Copy() *Array[T]
- func (b *Array[T]) Delete(index int) (T, bool)
- func (b *Array[T]) DeleteRange(index, count int) Slice[T]
- func (b *Array[T]) DeleteRangeOptions(index, count int, opts DeleteRangeOptions) Slice[T]
- func (b *Array[T]) Descend(index int) iter.Seq[T]
- func (b *Array[T]) Drain() iter.Seq[T]
- func (b *Array[T]) DrainBackward() iter.Seq[T]
- func (b *Array[T]) Front() (T, bool)
- func (b *Array[T]) Get(index int) (T, bool)
- func (b *Array[T]) Insert(index int, item T) bool
- func (b *Array[T]) Len() int
- func (b *Array[T]) PopBack() (T, bool)
- func (b *Array[T]) PopBackIf(cond func(item T) bool) (T, bool)
- func (b *Array[T]) PopFront() (T, bool)
- func (b *Array[T]) PopFrontIf(cond func(item T) bool) (T, bool)
- func (b *Array[T]) PushBack(item T) bool
- func (b *Array[T]) PushFront(item T) bool
- func (b *Array[T]) Release()
- func (b *Array[T]) Replace(index int, item T) (T, bool)
- type ArrayOptions
- type DeleteRangeOptions
- type Deque
- func (b *Deque[T]) All() iter.Seq[T]
- func (b *Deque[T]) AllMut() iter.Seq[T]
- func (b *Deque[T]) At(pos int) (T, bool)
- func (b *Deque[T]) AtMut(pos int) (T, bool)
- func (b *Deque[T]) Back() (T, bool)
- func (b *Deque[T]) BackMut() (T, bool)
- func (b *Deque[T]) Backward() iter.Seq[T]
- func (b *Deque[T]) BackwardMut() iter.Seq[T]
- func (b *Deque[T]) Clear()
- func (b *Deque[T]) Copy() *Deque[T]
- func (b *Deque[T]) Drain() iter.Seq[T]
- func (b *Deque[T]) DrainBackward() iter.Seq[T]
- func (b *Deque[T]) Front() (T, bool)
- func (b *Deque[T]) FrontMut() (T, bool)
- func (b *Deque[T]) Len() int
- func (b *Deque[T]) PopBack() (T, bool)
- func (b *Deque[T]) PopBackIf(cond func(item T) bool) (T, bool)
- func (b *Deque[T]) PopFront() (T, bool)
- func (b *Deque[T]) PopFrontIf(cond func(item T) bool) (T, bool)
- func (b *Deque[T]) PushBack(item T)
- func (b *Deque[T]) PushFront(item T)
- func (b *Deque[T]) Release()
- type DequeOptions
- type Map
- func (b *Map[K, V]) All() iter.Seq2[K, V]
- func (b *Map[K, V]) AllMut() iter.Seq2[K, V]
- func (b *Map[K, V]) Ascend(key K) iter.Seq2[K, V]
- func (b *Map[K, V]) AscendAt(index int) iter.Seq2[K, V]
- func (b *Map[K, V]) AscendAtMut(index int) iter.Seq2[K, V]
- func (b *Map[K, V]) AscendMut(key K) iter.Seq2[K, V]
- func (b *Map[K, V]) Back() (K, V, bool)
- func (b *Map[K, V]) BackMut() (K, V, bool)
- func (b *Map[K, V]) Backward() iter.Seq2[K, V]
- func (b *Map[K, V]) BackwardMut() iter.Seq2[K, V]
- func (b *Map[K, V]) Clear()
- func (b *Map[K, V]) Contains(key K) bool
- func (b *Map[K, V]) Copy() *Map[K, V]
- func (b *Map[K, V]) Delete(key K) (V, bool)
- func (b *Map[K, V]) DeleteAt(index int) (K, V, bool)
- func (b *Map[K, V]) DeleteRange(min, max K) Slice2[K, V]
- func (b *Map[K, V]) DeleteRangeAt(index, count int) Slice2[K, V]
- func (b *Map[K, V]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions) Slice2[K, V]
- func (b *Map[K, V]) DeleteRangeOptions(min, max K, opts DeleteRangeOptions) Slice2[K, V]
- func (b *Map[K, V]) Descend(key K) iter.Seq2[K, V]
- func (b *Map[K, V]) DescendAt(index int) iter.Seq2[K, V]
- func (b *Map[K, V]) DescendAtMut(index int) iter.Seq2[K, V]
- func (b *Map[K, V]) DescendMut(key K) iter.Seq2[K, V]
- func (b *Map[K, V]) Drain() iter.Seq2[K, V]
- func (b *Map[K, V]) DrainBackward() iter.Seq2[K, V]
- func (b *Map[K, V]) Front() (K, V, bool)
- func (b *Map[K, V]) FrontMut() (K, V, bool)
- func (b *Map[K, V]) Get(key K) (V, bool)
- func (b *Map[K, V]) GetAt(index int) (K, V, bool)
- func (b *Map[K, V]) GetAtMut(index int) (K, V, bool)
- func (b *Map[K, V]) GetMut(key K) (V, bool)
- func (b *Map[K, V]) IndexOf(key K) (int, bool)
- func (b *Map[K, V]) Insert(key K, value V) (V, bool)
- func (b *Map[K, V]) InsertAt(index int, key K, value V) bool
- func (b *Map[K, V]) Keys() iter.Seq[K]
- func (b *Map[K, V]) Len() int
- func (b *Map[K, V]) PopBack() (K, V, bool)
- func (b *Map[K, V]) PopBackIf(cond func(key K, value V) bool) (K, V, bool)
- func (b *Map[K, V]) PopFront() (K, V, bool)
- func (b *Map[K, V]) PopFrontIf(cond func(key K, value V) bool) (K, V, bool)
- func (b *Map[K, V]) PushBack(key K, value V) bool
- func (b *Map[K, V]) PushFront(key K, value V) bool
- func (b *Map[K, V]) Release()
- func (b *Map[K, V]) Replace(key K, value V) (V, bool)
- func (b *Map[K, V]) ReplaceAt(index int, key K, value V) (K, V, bool)
- func (b *Map[K, V]) Seek(key K) (K, V, bool)
- func (b *Map[K, V]) SeekMut(key K) (K, V, bool)
- func (b *Map[K, V]) SeekNext(key K) (K, V, bool)
- func (b *Map[K, V]) SeekNextMut(key K) (K, V, bool)
- func (b *Map[K, V]) SeekPrev(key K) (K, V, bool)
- func (b *Map[K, V]) SeekPrevMut(key K) (K, V, bool)
- func (b *Map[K, V]) Set(key K, value V) (V, bool)
- func (b *Map[K, V]) Values() iter.Seq[V]
- func (b *Map[K, V]) ValuesMut() iter.Seq[V]
- type MapOptions
- type Prique
- func (b *Prique[T]) All() iter.Seq[T]
- func (b *Prique[T]) AllMut() iter.Seq[T]
- func (b *Prique[T]) At(pos int) (T, bool)
- func (b *Prique[T]) AtMut(pos int) (T, bool)
- func (b *Prique[T]) Clear()
- func (b *Prique[T]) Copy() *Prique[T]
- func (b *Prique[T]) Delete(key T) (T, bool)
- func (b *Prique[T]) Drain() iter.Seq[T]
- func (b *Prique[T]) Front() (T, bool)
- func (b *Prique[T]) FrontMut() (T, bool)
- func (b *Prique[T]) Len() int
- func (b *Prique[T]) Pop() (T, bool)
- func (b *Prique[T]) PopIf(cond func(item T) bool) (T, bool)
- func (b *Prique[T]) Push(item T) bool
- func (b *Prique[T]) Release()
- type PriqueOptions
- type Queue
- func (b *Queue[T]) All() iter.Seq[T]
- func (b *Queue[T]) AllMut() iter.Seq[T]
- func (b *Queue[T]) At(pos int) (T, bool)
- func (b *Queue[T]) AtMut(pos int) (T, bool)
- func (b *Queue[T]) Clear()
- func (b *Queue[T]) Copy() *Queue[T]
- func (b *Queue[K]) Drain() iter.Seq[K]
- func (b *Queue[T]) Front() (T, bool)
- func (b *Queue[T]) FrontMut() (T, bool)
- func (b *Queue[T]) Len() int
- func (b *Queue[T]) Pop() (T, bool)
- func (b *Queue[T]) PopIf(cond func(item T) bool) (T, bool)
- func (b *Queue[T]) Push(item T)
- func (b *Queue[T]) Release()
- type QueueOptions
- type Set
- func (b *Set[K]) All() iter.Seq[K]
- func (b *Set[K]) Ascend(key K) iter.Seq[K]
- func (b *Set[K]) AscendAt(index int) iter.Seq[K]
- func (b *Set[K]) Back() (K, bool)
- func (b *Set[K]) Backward() iter.Seq[K]
- func (b *Set[K]) Clear()
- func (b *Set[K]) Contains(key K) bool
- func (b *Set[K]) Copy() *Set[K]
- func (b *Set[K]) Delete(key K) bool
- func (b *Set[K]) DeleteAt(index int) (K, bool)
- func (b *Set[K]) DeleteRange(min, max K) Slice[K]
- func (b *Set[K]) DeleteRangeAt(index, count int) Slice[K]
- func (b *Set[K]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions) Slice[K]
- func (b *Set[K]) DeleteRangeOptions(min, max K, opts DeleteRangeOptions) Slice[K]
- func (b *Set[K]) Descend(key K) iter.Seq[K]
- func (b *Set[K]) DescendAt(index int) iter.Seq[K]
- func (b *Set[K]) Drain() iter.Seq[K]
- func (b *Set[K]) DrainBackward() iter.Seq[K]
- func (b *Set[K]) Front() (K, bool)
- func (b *Set[K]) GetAt(index int) (K, bool)
- func (b *Set[K]) IndexOf(key K) (int, bool)
- func (b *Set[K]) Insert(key K) bool
- func (b *Set[K]) InsertAt(index int, key K) bool
- func (b *Set[K]) Len() int
- func (b *Set[K]) PopBack() (K, bool)
- func (b *Set[K]) PopBackIf(cond func(key K) bool) (K, bool)
- func (b *Set[K]) PopFront() (K, bool)
- func (b *Set[K]) PopFrontIf(cond func(key K) bool) (K, bool)
- func (b *Set[K]) PushBack(key K) bool
- func (b *Set[K]) PushFront(key K) bool
- func (b *Set[K]) Release()
- func (b *Set[K]) ReplaceAt(index int, key K) (K, bool)
- func (b *Set[K]) Seek(key K) (K, bool)
- func (b *Set[K]) SeekNext(key K) (K, bool)
- func (b *Set[K]) SeekPrev(key K) (K, bool)
- type Slice
- type Slice2
- type Stack
- func (b *Stack[T]) All() iter.Seq[T]
- func (b *Stack[T]) AllMut() iter.Seq[T]
- func (b *Stack[T]) At(pos int) (T, bool)
- func (b *Stack[T]) AtMut(pos int) (T, bool)
- func (b *Stack[T]) Clear()
- func (b *Stack[T]) Copy() *Stack[T]
- func (b *Stack[K]) Drain() iter.Seq[K]
- func (b *Stack[T]) Len() int
- func (b *Stack[T]) Pop() (T, bool)
- func (b *Stack[T]) Push(item T)
- func (b *Stack[T]) Release()
- func (b *Stack[T]) Top() (T, bool)
- func (b *Stack[T]) TopMut() (T, bool)
- type StackOptions
- type Table
- func (b *Table[T]) All() iter.Seq[T]
- func (b *Table[T]) AllMut() iter.Seq[T]
- func (b *Table[T]) Ascend(pivot T) iter.Seq[T]
- func (b *Table[T]) AscendAt(index int) iter.Seq[T]
- func (b *Table[T]) AscendAtMut(index int) iter.Seq[T]
- func (b *Table[T]) AscendMut(pivot T) iter.Seq[T]
- func (b *Table[T]) Back() (T, bool)
- func (b *Table[T]) BackMut() (T, bool)
- func (b *Table[T]) Backward() iter.Seq[T]
- func (b *Table[T]) BackwardMut() iter.Seq[T]
- func (b *Table[T]) Clear()
- func (b *Table[T]) Contains(key T) bool
- func (b *Table[T]) Copy() *Table[T]
- func (b *Table[T]) Delete(key T) (T, bool)
- func (b *Table[T]) DeleteAt(index int) (T, bool)
- func (b *Table[T]) DeleteRange(min, max T) Slice[T]
- func (b *Table[T]) DeleteRangeAt(index, count int) Slice[T]
- func (b *Table[T]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions) Slice[T]
- func (b *Table[T]) DeleteRangeOptions(min, max T, opts DeleteRangeOptions) Slice[T]
- func (b *Table[T]) Descend(pivot T) iter.Seq[T]
- func (b *Table[T]) DescendAt(index int) iter.Seq[T]
- func (b *Table[T]) DescendAtMut(index int) iter.Seq[T]
- func (b *Table[T]) DescendMut(pivot T) iter.Seq[T]
- func (b *Table[T]) Drain() iter.Seq[T]
- func (b *Table[T]) DrainBackward() iter.Seq[T]
- func (b *Table[T]) Front() (T, bool)
- func (b *Table[T]) FrontMut() (T, bool)
- func (b *Table[T]) Get(key T) (T, bool)
- func (b *Table[T]) GetAt(index int) (T, bool)
- func (b *Table[T]) GetAtMut(index int) (T, bool)
- func (b *Table[T]) GetMut(key T) (T, bool)
- func (b *Table[T]) IndexOf(key T) (int, bool)
- func (b *Table[T]) Insert(item T) (T, bool)
- func (b *Table[T]) InsertAt(index int, item T) bool
- func (b *Table[T]) Len() int
- func (b *Table[T]) PopBack() (T, bool)
- func (b *Table[T]) PopBackIf(cond func(item T) bool) (T, bool)
- func (b *Table[T]) PopFront() (T, bool)
- func (b *Table[T]) PopFrontIf(cond func(item T) bool) (T, bool)
- func (b *Table[T]) PushBack(item T) bool
- func (b *Table[T]) PushFront(item T) bool
- func (b *Table[T]) Release()
- func (b *Table[T]) Replace(item T) (T, bool)
- func (b *Table[T]) ReplaceAt(index int, item T) (T, bool)
- func (b *Table[T]) Seek(key T) (T, bool)
- func (b *Table[T]) SeekMut(key T) (T, bool)
- func (b *Table[T]) SeekNext(key T) (T, bool)
- func (b *Table[T]) SeekNextMut(key T) (T, bool)
- func (b *Table[T]) SeekPrev(key T) (T, bool)
- func (b *Table[T]) SeekPrevMut(key T) (T, bool)
- func (b *Table[T]) Set(item T) (T, bool)
- type TableOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareFor ¶
Return a compare function for type or nil if type is not comparable
Types ¶
type Array ¶
type Array[T any] struct { // contains filtered or unexported fields }
func NewArrayOptions ¶
func NewArrayOptions[T any](opts ArrayOptions[T]) *Array[T]
func (*Array[T]) DeleteRange ¶
func (*Array[T]) DeleteRangeOptions ¶
func (b *Array[T]) DeleteRangeOptions(index, count int, opts DeleteRangeOptions, ) Slice[T]
func (*Array[T]) DrainBackward ¶
func (*Array[T]) PopFrontIf ¶ added in v0.3.0
type ArrayOptions ¶
type ArrayOptions[T any] struct { Copy func(T) T Release func(T) }
type DeleteRangeOptions ¶
type Deque ¶
type Deque[T any] struct { // contains filtered or unexported fields }
Deque is a double-ended queue
func NewDequeOptions ¶
func NewDequeOptions[T any](opts DequeOptions[T]) *Deque[T]
func (*Deque[T]) AllMut ¶
All returns an iterator of all items starting with the first. MUTABLE OPERATION.
func (*Deque[T]) At ¶
At returns the item At position, after first, in queue. Returns false if no item is found At position.
func (*Deque[T]) AtMut ¶
AtMut returns the item at position, after first, in queue. Returns false if no item is found at position. MUTABLE OPERATION.
func (*Deque[T]) BackwardMut ¶
All returns an iterator of all items starting with the last. MUTABLE OPERATION.
func (*Deque[T]) DrainBackward ¶
func (*Deque[T]) PopFrontIf ¶ added in v0.3.0
type DequeOptions ¶
type DequeOptions[T any] struct { Copy func(T) T Release func(T) }
type Map ¶
func NewMapOptions ¶
func NewMapOptions[K cmp.Ordered, V any](opts MapOptions[K, V]) *Map[K, V]
func (*Map[K, V]) BackwardMut ¶
func (*Map[K, V]) DeleteRange ¶
func (*Map[K, V]) DeleteRangeAt ¶
func (*Map[K, V]) DeleteRangeAtOptions ¶
func (b *Map[K, V]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions, ) Slice2[K, V]
func (*Map[K, V]) DeleteRangeOptions ¶
func (b *Map[K, V]) DeleteRangeOptions(min, max K, opts DeleteRangeOptions, ) Slice2[K, V]
func (*Map[K, V]) DescendMut ¶
func (*Map[K, V]) DrainBackward ¶
func (*Map[K, V]) PopFrontIf ¶ added in v0.3.0
func (*Map[K, V]) SeekNextMut ¶
func (*Map[K, V]) SeekPrevMut ¶
type MapOptions ¶
type Prique ¶
type Prique[T any] struct { // contains filtered or unexported fields }
func NewPriqueOptions ¶
func NewPriqueOptions[T any](opts PriqueOptions[T]) *Prique[T]
func (*Prique[T]) At ¶
At returns the item At position, after first, in queue. Returns false if no item is found At position.
func (*Prique[T]) AtMut ¶
AtMut returns the item at position, after first, in queue. Returns false if no item is found at position. MUTABLE OPERATION.
func (*Prique[T]) Copy ¶
Copy the queue. This is a fast O(1) operation using a copy-on-write method.
func (*Prique[T]) Delete ¶
Delete item with the provided key. If duplicate items with the same key exist, only one will be deleted; specifically the oldest duplicate item is deleted.
type PriqueOptions ¶
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue provides the functionality of a queue - specifically, a FIFO (first-in, first-out) data structure.
func NewQueueOptions ¶
func NewQueueOptions[T any](opts QueueOptions[T]) *Queue[T]
func (*Queue[T]) AllMut ¶
All returns an iterator of all items starting with the first. MUTABLE OPERATION.
func (*Queue[T]) At ¶
At returns the item At position, after first, in queue. Returns false if no item is found At position.
func (*Queue[T]) AtMut ¶
AtMut returns the item at position, after first, in queue. Returns false if no item is found at position. MUTABLE OPERATION.
type QueueOptions ¶
type QueueOptions[T any] struct { Copy func(T) T Release func(T) }
type Set ¶
func (*Set[K]) DeleteRange ¶
func (*Set[K]) DeleteRangeAt ¶
func (*Set[K]) DeleteRangeAtOptions ¶
func (b *Set[K]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions, ) Slice[K]
func (*Set[K]) DeleteRangeOptions ¶
func (b *Set[K]) DeleteRangeOptions(min, max K, opts DeleteRangeOptions, ) Slice[K]
func (*Set[K]) DrainBackward ¶
func (*Set[K]) PopFrontIf ¶ added in v0.3.0
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack provides the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure.
func NewStackOptions ¶
func NewStackOptions[T any](opts StackOptions[T]) *Stack[T]
func (*Stack[T]) AllMut ¶
AllMut returns an iterator of all items starting from the top of the stack. MUTABLE OPERATION.
func (*Stack[T]) At ¶
At returns the item At position, after top, in Stack. Returns false if no item is found At position.
func (*Stack[T]) AtMut ¶
AtMut returns the item at position, after top, in Stack. Returns false if no item is found at position. MUTABLE OPERATION.
func (*Stack[T]) Release ¶
func (b *Stack[T]) Release()
Release will clear the stack and releases any copied reference. This method is functionally equivalent to Clear() but is an optimization for collections that are copied using Copy().
type StackOptions ¶
type StackOptions[T any] struct { Copy func(T) T Release func(T) }
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
func NewTableOptions ¶
func NewTableOptions[T any](opts TableOptions[T]) *Table[T]
func (*Table[T]) BackwardMut ¶
func (*Table[T]) DeleteRange ¶
func (*Table[T]) DeleteRangeAt ¶
func (*Table[T]) DeleteRangeAtOptions ¶
func (b *Table[T]) DeleteRangeAtOptions(index, count int, opts DeleteRangeOptions, ) Slice[T]
func (*Table[T]) DeleteRangeOptions ¶
func (b *Table[T]) DeleteRangeOptions(min, max T, opts DeleteRangeOptions, ) Slice[T]