2026-08-01から1ヶ月間の記事一覧
en.wikipedia.org package b_plus_tree import ( "errors" "slices" ) var ErrKeyNotFound = errors.New("key not found") type Entry[K any, V any] struct { key K value V } func NewEntry[K any, V any](key K, value V) *Entry[K, V] { return &Entry[K…
en.wikipedia.org package b_tree type BTree struct { t int // minimum degree root *Node } type Node struct { keys []int children []*Node keyCount int leaf bool } func NewBTree(minimumDegree int) *BTree { if minimumDegree < 2 { panic("minimu…
en.wikipedia.org package red_black_tree type Node struct { value int color bool left *Node right *Node parent *Node } func NewNode(value int, color bool) *Node { return &Node{ value: value, color: color, } } const ( RED bool = true BLACK b…
en.wikipedia.org package avl_tree import "errors" type Node struct { value int height int left *Node right *Node } func NewNode(value int) *Node { return &Node{ value: value, height: 1, } } type AVLTree struct { root *Node size int } func …
en.wikipedia.org package binary_search_tree2 import "errors" type Node struct { value int left *Node right *Node } func NewNode(value int) *Node { return &Node{value: value} } type BinarySearchTree struct { root *Node size int } func (b *B…
ここ最近の記事で書いたアルゴリズムをまとめてredisのような物をAIで作ってベンチ取ってみました redispoi 開発レポート 自作アルゴリズム実装群を RESP プロトコル(Redis 互換プロトコル)サーバーへ統合し、 ユニットテストとベンチマークを整備した記録。…
package t_digest import ( "math" "sort" ) type Centroid struct { mean float64 weight int } func NewCentroid(mean float64, weight int) *Centroid { return &Centroid{ mean: mean, weight: weight, } } func (c *Centroid) add(value float64, addit…
www.usenix.org package heavy_keeper_top_k import ( "cmp" "errors" "fmt" "math" "math/rand" "slices" "time" ) type Bucket struct { fingerprint int count int } type Result struct { item string estimatedCount int64 } func NewResult(item strin…
en.wikipedia.org package count_min_sketch import "math" type CountMinSketch struct { counters [][]int width int depth int seeds []uint64 totalCount int } func NewCountMinSketch(width, depth int) *CountMinSketch { if width <= 0 { panic("wid…
en.wikipedia.org package cuckoo_filter import ( "math" "math/bits" "math/rand" "time" ) const ( DEFAULT_BUCKET_SIZE = 4 DEFAULT_MAX_KICKS = 500 ) type CuckooFilter struct { bucketCount int bucketSize int maxKicks int fingerprintBits int bu…
en.wikipedia.org package bloom_filter import ( "math" "math/bits" ) type BitSet struct { bits []uint64 n int // ビット数 } func NewBitSet(n int) *BitSet { return &BitSet{ bits: make([]uint64, (n+63)/64), n: n, } } func (b *BitSet) Set(i in…