util

package
v0.0.0-...-6ef4fb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastRand

func FastRand() uint32

FastRand links to the runtime's fastrand function. This avoids the overhead of global locks or atomic contention in standard rand.

Types

type ArrayBlockingQueue

type ArrayBlockingQueue[E any] struct {
	// contains filtered or unexported fields
}

ArrayBlockingQueue v3: 终极物理优化版

优化点: 1. Channel Signal: 使用 buffered channel 替代 sync.Cond,实现原生高效超时和调度。 2. Cascading Wake-up: 读写操作后主动检测并传递信号,最大限度提高并发吞吐。 3. Unsafe Direct Access: 绕过 slice 边界检查。 4. Hybrid Spin: 纳秒级自旋。

func NewArrayBlockingQueue

func NewArrayBlockingQueue[E any](capacity int) *ArrayBlockingQueue[E]

func (*ArrayBlockingQueue[E]) Add

func (q *ArrayBlockingQueue[E]) Add(e E) bool

func (*ArrayBlockingQueue[E]) AddAll

func (q *ArrayBlockingQueue[E]) AddAll(c Collection[E]) bool

func (*ArrayBlockingQueue[E]) All

func (q *ArrayBlockingQueue[E]) All() iter.Seq[E]

func (*ArrayBlockingQueue[E]) Clear

func (q *ArrayBlockingQueue[E]) Clear()

func (*ArrayBlockingQueue[E]) Contains

func (q *ArrayBlockingQueue[E]) Contains(o E) bool

func (*ArrayBlockingQueue[E]) ContainsAll

func (q *ArrayBlockingQueue[E]) ContainsAll(c Collection[E]) bool

--- Unsupported Operations ---

func (*ArrayBlockingQueue[E]) DrainTo

func (q *ArrayBlockingQueue[E]) DrainTo(c Collection[E]) int

func (*ArrayBlockingQueue[E]) DrainToN

func (q *ArrayBlockingQueue[E]) DrainToN(c Collection[E], maxElements int) int

func (*ArrayBlockingQueue[E]) Element

func (q *ArrayBlockingQueue[E]) Element() E

func (*ArrayBlockingQueue[E]) IsEmpty

func (q *ArrayBlockingQueue[E]) IsEmpty() bool

func (*ArrayBlockingQueue[E]) Offer

func (q *ArrayBlockingQueue[E]) Offer(e E) bool

func (*ArrayBlockingQueue[E]) OfferTimeout

func (q *ArrayBlockingQueue[E]) OfferTimeout(e E, timeout time.Duration) bool

func (*ArrayBlockingQueue[E]) Peek

func (q *ArrayBlockingQueue[E]) Peek() (E, bool)

func (*ArrayBlockingQueue[E]) Poll

func (q *ArrayBlockingQueue[E]) Poll() (E, bool)

func (*ArrayBlockingQueue[E]) PollTimeout

func (q *ArrayBlockingQueue[E]) PollTimeout(timeout time.Duration) (E, bool)

func (*ArrayBlockingQueue[E]) Put

func (q *ArrayBlockingQueue[E]) Put(e E)

func (*ArrayBlockingQueue[E]) RemainingCapacity

func (q *ArrayBlockingQueue[E]) RemainingCapacity() int

func (*ArrayBlockingQueue[E]) Remove

func (q *ArrayBlockingQueue[E]) Remove(o E) bool

func (*ArrayBlockingQueue[E]) RemoveAll

func (q *ArrayBlockingQueue[E]) RemoveAll(c Collection[E]) bool

func (*ArrayBlockingQueue[E]) RemoveHead

func (q *ArrayBlockingQueue[E]) RemoveHead() E

func (*ArrayBlockingQueue[E]) RetainAll

func (q *ArrayBlockingQueue[E]) RetainAll(c Collection[E]) bool

func (*ArrayBlockingQueue[E]) Size

func (q *ArrayBlockingQueue[E]) Size() int

func (*ArrayBlockingQueue[E]) Take

func (q *ArrayBlockingQueue[E]) Take() E

func (*ArrayBlockingQueue[E]) ToSlice

func (q *ArrayBlockingQueue[E]) ToSlice() []E

type ArrayDeque

type ArrayDeque[E any] struct {
	// contains filtered or unexported fields
}

ArrayDeque 基于循环数组的双端队列

性能特征: 1. 时间复杂度: 所有的插入/删除/获取操作均为严格的 O(1) (Amortized)。 2. 内存布局: Power of 2 容量设计,使用位运算 (& mask) 替代取模 (%),CPU 周期从 ~20 降至 ~1。 3. 缓存友好: 核心字段 (head, tail, mask) 紧凑排列,适应 L1 Cache Line。 4. 迭代器: 支持 Go 1.23 零内存分配迭代 (iter.Seq)。

func NewArrayDeque

func NewArrayDeque[E any](numElements ...int) *ArrayDeque[E]

func NewArrayDequeFrom

func NewArrayDequeFrom[E any](c Collection[E]) *ArrayDeque[E]

func (*ArrayDeque[E]) Add

func (q *ArrayDeque[E]) Add(e E) bool

func (*ArrayDeque[E]) AddAll

func (q *ArrayDeque[E]) AddAll(c Collection[E]) bool

func (*ArrayDeque[E]) AddFirst

func (q *ArrayDeque[E]) AddFirst(e E)

AddFirst O(1)

func (*ArrayDeque[E]) AddLast

func (q *ArrayDeque[E]) AddLast(e E)

AddLast O(1)

func (*ArrayDeque[E]) All

func (q *ArrayDeque[E]) All() iter.Seq[E]

All Go 1.23+ 风格迭代器 优势: 栈上分配,无 Interface 开销,内联友好

func (*ArrayDeque[E]) Clear

func (q *ArrayDeque[E]) Clear()

func (*ArrayDeque[E]) Clone

func (q *ArrayDeque[E]) Clone() *ArrayDeque[E]

func (*ArrayDeque[E]) Contains

func (q *ArrayDeque[E]) Contains(e E) bool

func (*ArrayDeque[E]) ContainsAll

func (q *ArrayDeque[E]) ContainsAll(c Collection[E]) bool

func (*ArrayDeque[E]) DescendingAll

func (q *ArrayDeque[E]) DescendingAll() iter.Seq[E]

func (*ArrayDeque[E]) DescendingIterator

func (q *ArrayDeque[E]) DescendingIterator() Iterator[E]

func (*ArrayDeque[E]) Element

func (q *ArrayDeque[E]) Element() E

func (*ArrayDeque[E]) GetFirst

func (q *ArrayDeque[E]) GetFirst() E

func (*ArrayDeque[E]) GetLast

func (q *ArrayDeque[E]) GetLast() E

func (*ArrayDeque[E]) Grow

func (q *ArrayDeque[E]) Grow(minCapacity int)

Grow 手动扩容 (Go 特有优化) 允许预先分配内存以避免多次扩容带来的性能抖动

func (*ArrayDeque[E]) IsEmpty

func (q *ArrayDeque[E]) IsEmpty() bool

func (*ArrayDeque[E]) Iterator

func (q *ArrayDeque[E]) Iterator() Iterator[E]

func (*ArrayDeque[E]) MarshalJSON

func (q *ArrayDeque[E]) MarshalJSON() ([]byte, error)

func (*ArrayDeque[E]) Offer

func (q *ArrayDeque[E]) Offer(e E) bool

func (*ArrayDeque[E]) OfferFirst

func (q *ArrayDeque[E]) OfferFirst(e E) bool

func (*ArrayDeque[E]) OfferLast

func (q *ArrayDeque[E]) OfferLast(e E) bool

func (*ArrayDeque[E]) Peek

func (q *ArrayDeque[E]) Peek() (E, bool)

func (*ArrayDeque[E]) PeekFirst

func (q *ArrayDeque[E]) PeekFirst() (E, bool)

PeekFirst O(1)

func (*ArrayDeque[E]) PeekLast

func (q *ArrayDeque[E]) PeekLast() (E, bool)

PeekLast O(1)

func (*ArrayDeque[E]) Poll

func (q *ArrayDeque[E]) Poll() (E, bool)

func (*ArrayDeque[E]) PollFirst

func (q *ArrayDeque[E]) PollFirst() (E, bool)

PollFirst O(1)

func (*ArrayDeque[E]) PollLast

func (q *ArrayDeque[E]) PollLast() (E, bool)

PollLast O(1)

func (*ArrayDeque[E]) Pop

func (q *ArrayDeque[E]) Pop() E

func (*ArrayDeque[E]) Push

func (q *ArrayDeque[E]) Push(e E)

func (*ArrayDeque[E]) Remove

func (q *ArrayDeque[E]) Remove(e E) bool

func (*ArrayDeque[E]) RemoveAll

func (q *ArrayDeque[E]) RemoveAll(c Collection[E]) bool

func (*ArrayDeque[E]) RemoveFirst

func (q *ArrayDeque[E]) RemoveFirst() E

func (*ArrayDeque[E]) RemoveFirstOccurrence

func (q *ArrayDeque[E]) RemoveFirstOccurrence(o E) bool

func (*ArrayDeque[E]) RemoveHead

func (q *ArrayDeque[E]) RemoveHead() E

func (*ArrayDeque[E]) RemoveIf

func (q *ArrayDeque[E]) RemoveIf(filter func(E) bool) bool

RemoveIf 批量删除优化算法

func (*ArrayDeque[E]) RemoveLast

func (q *ArrayDeque[E]) RemoveLast() E

func (*ArrayDeque[E]) RemoveLastOccurrence

func (q *ArrayDeque[E]) RemoveLastOccurrence(o E) bool

func (*ArrayDeque[E]) RetainAll

func (q *ArrayDeque[E]) RetainAll(c Collection[E]) bool

func (*ArrayDeque[E]) Reversed

func (q *ArrayDeque[E]) Reversed() []E

func (*ArrayDeque[E]) Size

func (q *ArrayDeque[E]) Size() int

func (*ArrayDeque[E]) String

func (q *ArrayDeque[E]) String() string

func (*ArrayDeque[E]) ToSlice

func (q *ArrayDeque[E]) ToSlice() []E

func (*ArrayDeque[E]) UnmarshalJSON

func (q *ArrayDeque[E]) UnmarshalJSON(data []byte) error

type ArrayList

type ArrayList[E any] struct {
	// contains filtered or unexported fields
}

ArrayList 基于切片的高性能动态数组实现 优化等级: Ultimate (RW-Split, SubList O(N) Compaction, memclr, slices.Grow)

func NewArrayList

func NewArrayList[E any](initialCapacity ...int) *ArrayList[E]

func NewArrayListFrom

func NewArrayListFrom[E any](source []E) *ArrayList[E]

func (*ArrayList[E]) Add

func (l *ArrayList[E]) Add(e E) bool

func (*ArrayList[E]) AddAll

func (l *ArrayList[E]) AddAll(c Collection[E]) bool

func (*ArrayList[E]) AddAllAtIndex

func (l *ArrayList[E]) AddAllAtIndex(index int, c Collection[E]) bool

func (*ArrayList[E]) AddAtIndex

func (l *ArrayList[E]) AddAtIndex(index int, element E)

func (*ArrayList[E]) AddFirst

func (l *ArrayList[E]) AddFirst(e E)

func (*ArrayList[E]) AddLast

func (l *ArrayList[E]) AddLast(e E)

func (*ArrayList[E]) All

func (l *ArrayList[E]) All() iter.Seq[E]

func (*ArrayList[E]) Clear

func (l *ArrayList[E]) Clear()

func (*ArrayList[E]) Clone

func (l *ArrayList[E]) Clone() *ArrayList[E]

func (*ArrayList[E]) Contains

func (l *ArrayList[E]) Contains(e E) bool

func (*ArrayList[E]) ContainsAll

func (l *ArrayList[E]) ContainsAll(c Collection[E]) bool

func (*ArrayList[E]) EnsureCapacity

func (l *ArrayList[E]) EnsureCapacity(minCapacity int)

辅助:手动管理容量

func (*ArrayList[E]) ForEach

func (l *ArrayList[E]) ForEach(action func(E))

func (*ArrayList[E]) Get

func (l *ArrayList[E]) Get(index int) E

func (*ArrayList[E]) GetFirst

func (l *ArrayList[E]) GetFirst() E

func (*ArrayList[E]) GetLast

func (l *ArrayList[E]) GetLast() E

func (*ArrayList[E]) IndexOf

func (l *ArrayList[E]) IndexOf(e E) int

func (*ArrayList[E]) IsEmpty

func (l *ArrayList[E]) IsEmpty() bool

func (*ArrayList[E]) LastIndexOf

func (l *ArrayList[E]) LastIndexOf(e E) int

func (*ArrayList[E]) ListIterator

func (l *ArrayList[E]) ListIterator() ListIterator[E]

func (*ArrayList[E]) MarshalJSON

func (l *ArrayList[E]) MarshalJSON() ([]byte, error)

func (*ArrayList[E]) Remove

func (l *ArrayList[E]) Remove(e E) bool

func (*ArrayList[E]) RemoveAll

func (l *ArrayList[E]) RemoveAll(c Collection[E]) bool

func (*ArrayList[E]) RemoveAtIndex

func (l *ArrayList[E]) RemoveAtIndex(index int) E

func (*ArrayList[E]) RemoveFirst

func (l *ArrayList[E]) RemoveFirst() E

func (*ArrayList[E]) RemoveIf

func (l *ArrayList[E]) RemoveIf(filter func(E) bool) bool

RemoveIf 读写分离优化版

func (*ArrayList[E]) RemoveLast

func (l *ArrayList[E]) RemoveLast() E

func (*ArrayList[E]) ReplaceAll

func (l *ArrayList[E]) ReplaceAll(operator func(E) E)

func (*ArrayList[E]) RetainAll

func (l *ArrayList[E]) RetainAll(c Collection[E]) bool

func (*ArrayList[E]) Reversed

func (l *ArrayList[E]) Reversed() []E

func (*ArrayList[E]) Set

func (l *ArrayList[E]) Set(index int, element E) E

func (*ArrayList[E]) Size

func (l *ArrayList[E]) Size() int

func (*ArrayList[E]) Sort

func (l *ArrayList[E]) Sort(less func(a, b E) int)

func (*ArrayList[E]) String

func (l *ArrayList[E]) String() string

func (*ArrayList[E]) SubList

func (l *ArrayList[E]) SubList(fromIndex, toIndex int) List[E]

func (*ArrayList[E]) ToSlice

func (l *ArrayList[E]) ToSlice() []E

func (*ArrayList[E]) TrimToSize

func (l *ArrayList[E]) TrimToSize()

func (*ArrayList[E]) UnmarshalJSON

func (l *ArrayList[E]) UnmarshalJSON(data []byte) error

type BlockingQueue

type BlockingQueue[E any] interface {
	Queue[E]

	// --- 阻塞等待 ---
	Put(e E) // 将指定元素插入此队列中,将等待可用的空间(如果有必要)
	Take() E // 获取并移除此队列的头部,在元素变得可用之前一直等待(如果有必要)

	// --- 带超时机制 ---
	OfferTimeout(e E, timeout time.Duration) bool // 插入元素,如果已满则等待指定时间
	PollTimeout(timeout time.Duration) (E, bool)  // 获取元素,如果为空则等待指定时间

	// --- 批量操作 ---
	RemainingCapacity() int                        // 返回在无阻塞的理想情况下(不存在内存或资源约束)此队列能接受的附加元素数量
	DrainTo(c Collection[E]) int                   // 移除此队列中所有可用的元素,并将它们添加到给定 collection 中
	DrainToN(c Collection[E], maxElements int) int // 最多移除给定数量的元素
}

BlockingQueue 阻塞队列接口 完全对标 java.util.concurrent.BlockingQueue

type Collection

type Collection[E any] interface {
	Size() int
	IsEmpty() bool
	Clear()
	Add(e E) bool
	Remove(e E) bool
	Contains(e E) bool
	ToSlice() []E
	All() iter.Seq[E]

	// --- 批量操作 ---
	ContainsAll(c Collection[E]) bool
	AddAll(c Collection[E]) bool
	RemoveAll(c Collection[E]) bool
	RetainAll(c Collection[E]) bool
}

Collection 基础集合接口

type Comparator

type Comparator[E any] func(a, b E) int

Comparator 比较函数

type ConcurrentArrayList

type ConcurrentArrayList[E comparable] struct {
	// contains filtered or unexported fields
}

ConcurrentArrayList 线程安全的动态数组 (Copy-On-Write 策略) 优化等级: Physical Limit (Cache Line Padding + SIMD + Atomic + Fast Path) 适用场景: 读多写少 (Read-Heavy),如配置中心、注册表、黑白名单 接口对标: java.util.concurrent.CopyOnWriteArrayList

func NewConcurrentArrayList

func NewConcurrentArrayList[E comparable](elements ...E) *ConcurrentArrayList[E]

func (*ConcurrentArrayList[E]) Add

func (l *ConcurrentArrayList[E]) Add(e E) bool

func (*ConcurrentArrayList[E]) AddAll

func (l *ConcurrentArrayList[E]) AddAll(c Collection[E]) bool

func (*ConcurrentArrayList[E]) AddAllAbsent

func (l *ConcurrentArrayList[E]) AddAllAbsent(c Collection[E]) int

func (*ConcurrentArrayList[E]) AddAllAtIndex

func (l *ConcurrentArrayList[E]) AddAllAtIndex(index int, c Collection[E]) bool

func (*ConcurrentArrayList[E]) AddAtIndex

func (l *ConcurrentArrayList[E]) AddAtIndex(index int, element E)

func (*ConcurrentArrayList[E]) AddFirst

func (l *ConcurrentArrayList[E]) AddFirst(e E)

func (*ConcurrentArrayList[E]) AddIfAbsent

func (l *ConcurrentArrayList[E]) AddIfAbsent(e E) bool

func (*ConcurrentArrayList[E]) AddLast

func (l *ConcurrentArrayList[E]) AddLast(e E)

func (*ConcurrentArrayList[E]) All

func (l *ConcurrentArrayList[E]) All() iter.Seq[E]

func (*ConcurrentArrayList[E]) Clear

func (l *ConcurrentArrayList[E]) Clear()

func (*ConcurrentArrayList[E]) Clone

func (l *ConcurrentArrayList[E]) Clone() *ConcurrentArrayList[E]

Clone O(1) 极速克隆

func (*ConcurrentArrayList[E]) Contains

func (l *ConcurrentArrayList[E]) Contains(e E) bool

func (*ConcurrentArrayList[E]) ContainsAll

func (l *ConcurrentArrayList[E]) ContainsAll(c Collection[E]) bool

func (*ConcurrentArrayList[E]) Equals

func (l *ConcurrentArrayList[E]) Equals(o any) bool

func (*ConcurrentArrayList[E]) ForEach

func (l *ConcurrentArrayList[E]) ForEach(action func(E))

func (*ConcurrentArrayList[E]) Get

func (l *ConcurrentArrayList[E]) Get(index int) E

func (*ConcurrentArrayList[E]) GetFirst

func (l *ConcurrentArrayList[E]) GetFirst() E

func (*ConcurrentArrayList[E]) GetFound

func (l *ConcurrentArrayList[E]) GetFound(index int) (E, bool)

func (*ConcurrentArrayList[E]) GetLast

func (l *ConcurrentArrayList[E]) GetLast() E

func (*ConcurrentArrayList[E]) HashCode

func (l *ConcurrentArrayList[E]) HashCode() int

func (*ConcurrentArrayList[E]) IndexOf

func (l *ConcurrentArrayList[E]) IndexOf(e E) int

func (*ConcurrentArrayList[E]) IndexOfFrom

func (l *ConcurrentArrayList[E]) IndexOfFrom(e E, index int) int

func (*ConcurrentArrayList[E]) IsEmpty

func (l *ConcurrentArrayList[E]) IsEmpty() bool

func (*ConcurrentArrayList[E]) LastIndexOf

func (l *ConcurrentArrayList[E]) LastIndexOf(e E) int

func (*ConcurrentArrayList[E]) LastIndexOfFrom

func (l *ConcurrentArrayList[E]) LastIndexOfFrom(e E, index int) int

func (*ConcurrentArrayList[E]) ListIterator

func (l *ConcurrentArrayList[E]) ListIterator() ListIterator[E]

func (*ConcurrentArrayList[E]) ListIteratorIndex

func (l *ConcurrentArrayList[E]) ListIteratorIndex(index int) ListIterator[E]

func (*ConcurrentArrayList[E]) MarshalJSON

func (l *ConcurrentArrayList[E]) MarshalJSON() ([]byte, error)

func (*ConcurrentArrayList[E]) Remove

func (l *ConcurrentArrayList[E]) Remove(e E) bool

func (*ConcurrentArrayList[E]) RemoveAll

func (l *ConcurrentArrayList[E]) RemoveAll(c Collection[E]) bool

func (*ConcurrentArrayList[E]) RemoveAtIndex

func (l *ConcurrentArrayList[E]) RemoveAtIndex(index int) E

func (*ConcurrentArrayList[E]) RemoveFirst

func (l *ConcurrentArrayList[E]) RemoveFirst() E

func (*ConcurrentArrayList[E]) RemoveIf

func (l *ConcurrentArrayList[E]) RemoveIf(filter func(E) bool) bool

func (*ConcurrentArrayList[E]) RemoveLast

func (l *ConcurrentArrayList[E]) RemoveLast() E

func (*ConcurrentArrayList[E]) ReplaceAll

func (l *ConcurrentArrayList[E]) ReplaceAll(operator func(E) E)

func (*ConcurrentArrayList[E]) RetainAll

func (l *ConcurrentArrayList[E]) RetainAll(c Collection[E]) bool

func (*ConcurrentArrayList[E]) Reversed

func (l *ConcurrentArrayList[E]) Reversed() []E

func (*ConcurrentArrayList[E]) Set

func (l *ConcurrentArrayList[E]) Set(index int, element E) E

func (*ConcurrentArrayList[E]) Size

func (l *ConcurrentArrayList[E]) Size() int

func (*ConcurrentArrayList[E]) Sort

func (l *ConcurrentArrayList[E]) Sort(less func(a, b E) int)

func (*ConcurrentArrayList[E]) String

func (l *ConcurrentArrayList[E]) String() string

func (*ConcurrentArrayList[E]) SubList

func (l *ConcurrentArrayList[E]) SubList(fromIndex, toIndex int) List[E]

func (*ConcurrentArrayList[E]) ToSlice

func (l *ConcurrentArrayList[E]) ToSlice() []E

func (*ConcurrentArrayList[E]) UnmarshalJSON

func (l *ConcurrentArrayList[E]) UnmarshalJSON(data []byte) error

type ConcurrentArraySet

type ConcurrentArraySet[E comparable] struct {
	// contains filtered or unexported fields
}

ConcurrentArraySet 基于 Copy-On-Write 策略的线程安全集合 核心原理: 内部 *嵌入* ConcurrentArrayList,减少一层指针间接寻址。 优化等级: Physical Limit (Struct Embedding + White-box Access + Smart Dedupe) 适用场景: 读多写少、配置中心、黑白名单 (Set 语义需要 O(N) 查找) 接口对标: java.util.concurrent.CopyOnWriteArraySet

func NewConcurrentArraySet

func NewConcurrentArraySet[E comparable](elements ...E) *ConcurrentArraySet[E]

func (*ConcurrentArraySet[E]) Add

func (s *ConcurrentArraySet[E]) Add(e E) bool

func (*ConcurrentArraySet[E]) AddAll

func (s *ConcurrentArraySet[E]) AddAll(c Collection[E]) bool

func (*ConcurrentArraySet[E]) All

func (s *ConcurrentArraySet[E]) All() iter.Seq[E]

func (*ConcurrentArraySet[E]) Clear

func (s *ConcurrentArraySet[E]) Clear()

func (*ConcurrentArraySet[E]) Clone

func (s *ConcurrentArraySet[E]) Clone() *ConcurrentArraySet[E]

Clone O(1) 共享底层数组 (White-box)

func (*ConcurrentArraySet[E]) Contains

func (s *ConcurrentArraySet[E]) Contains(e E) bool

func (*ConcurrentArraySet[E]) ContainsAll

func (s *ConcurrentArraySet[E]) ContainsAll(c Collection[E]) bool

func (*ConcurrentArraySet[E]) Equals

func (s *ConcurrentArraySet[E]) Equals(o any) bool

func (*ConcurrentArraySet[E]) IsEmpty

func (s *ConcurrentArraySet[E]) IsEmpty() bool

func (*ConcurrentArraySet[E]) MarshalJSON

func (s *ConcurrentArraySet[E]) MarshalJSON() ([]byte, error)

func (*ConcurrentArraySet[E]) Remove

func (s *ConcurrentArraySet[E]) Remove(e E) bool

func (*ConcurrentArraySet[E]) RemoveAll

func (s *ConcurrentArraySet[E]) RemoveAll(c Collection[E]) bool

func (*ConcurrentArraySet[E]) RemoveIf

func (s *ConcurrentArraySet[E]) RemoveIf(filter func(E) bool) bool

func (*ConcurrentArraySet[E]) RetainAll

func (s *ConcurrentArraySet[E]) RetainAll(c Collection[E]) bool

func (*ConcurrentArraySet[E]) Size

func (s *ConcurrentArraySet[E]) Size() int

func (*ConcurrentArraySet[E]) String

func (s *ConcurrentArraySet[E]) String() string

func (*ConcurrentArraySet[E]) ToSlice

func (s *ConcurrentArraySet[E]) ToSlice() []E

func (*ConcurrentArraySet[E]) UnmarshalJSON

func (s *ConcurrentArraySet[E]) UnmarshalJSON(data []byte) error

type ConcurrentHashMap

type ConcurrentHashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

ConcurrentHashMap 线程安全的高性能哈希表 优化等级: Ultimate (Unsafe Pointer Arithmetic, Bit-Twiddling, Static Hasher, Cache-Line Aligned)

func NewConcurrentHashMap

func NewConcurrentHashMap[K comparable, V any](options ...int) *ConcurrentHashMap[K, V]

NewConcurrentHashMap 创建一个新的并发 Map

func (*ConcurrentHashMap[K, V]) Clear

func (m *ConcurrentHashMap[K, V]) Clear()

func (*ConcurrentHashMap[K, V]) Clone

func (m *ConcurrentHashMap[K, V]) Clone() *ConcurrentHashMap[K, V]

func (*ConcurrentHashMap[K, V]) Compute

func (m *ConcurrentHashMap[K, V]) Compute(key K, remappingFunction func(K, V) V) V

func (*ConcurrentHashMap[K, V]) ComputeIfAbsent

func (m *ConcurrentHashMap[K, V]) ComputeIfAbsent(key K, mappingFunction func(K) V) V

func (*ConcurrentHashMap[K, V]) ComputeIfPresent

func (m *ConcurrentHashMap[K, V]) ComputeIfPresent(key K, remappingFunction func(K, V) V) V

func (*ConcurrentHashMap[K, V]) ContainsKey

func (m *ConcurrentHashMap[K, V]) ContainsKey(key K) bool

func (*ConcurrentHashMap[K, V]) ContainsValue

func (m *ConcurrentHashMap[K, V]) ContainsValue(value V) bool

func (*ConcurrentHashMap[K, V]) EntrySet

func (m *ConcurrentHashMap[K, V]) EntrySet() Set[Entry[K, V]]

func (*ConcurrentHashMap[K, V]) ForEach

func (m *ConcurrentHashMap[K, V]) ForEach(action func(K, V))

func (*ConcurrentHashMap[K, V]) Get

func (m *ConcurrentHashMap[K, V]) Get(key K) V

func (*ConcurrentHashMap[K, V]) GetFound

func (m *ConcurrentHashMap[K, V]) GetFound(key K) (V, bool)

func (*ConcurrentHashMap[K, V]) GetOrDefault

func (m *ConcurrentHashMap[K, V]) GetOrDefault(key K, defaultValue V) V

func (*ConcurrentHashMap[K, V]) IsEmpty

func (m *ConcurrentHashMap[K, V]) IsEmpty() bool

func (*ConcurrentHashMap[K, V]) Keys

func (m *ConcurrentHashMap[K, V]) Keys() Set[K]

func (*ConcurrentHashMap[K, V]) MarshalJSON

func (m *ConcurrentHashMap[K, V]) MarshalJSON() ([]byte, error)

func (*ConcurrentHashMap[K, V]) Merge

func (m *ConcurrentHashMap[K, V]) Merge(key K, value V, remappingFunction func(oldV, newV V) V) V

func (*ConcurrentHashMap[K, V]) Put

func (m *ConcurrentHashMap[K, V]) Put(key K, value V)

func (*ConcurrentHashMap[K, V]) PutAll

func (m *ConcurrentHashMap[K, V]) PutAll(other Map[K, V])

func (*ConcurrentHashMap[K, V]) PutIfAbsent

func (m *ConcurrentHashMap[K, V]) PutIfAbsent(key K, value V) V

func (*ConcurrentHashMap[K, V]) Remove

func (m *ConcurrentHashMap[K, V]) Remove(key K) bool

func (*ConcurrentHashMap[K, V]) RemoveEntry

func (m *ConcurrentHashMap[K, V]) RemoveEntry(key K, value V) bool

func (*ConcurrentHashMap[K, V]) Replace

func (m *ConcurrentHashMap[K, V]) Replace(key K, oldValue V, newValue V) bool

func (*ConcurrentHashMap[K, V]) ReplaceAll

func (m *ConcurrentHashMap[K, V]) ReplaceAll(function func(K, V) V)

func (*ConcurrentHashMap[K, V]) Size

func (m *ConcurrentHashMap[K, V]) Size() int

func (*ConcurrentHashMap[K, V]) UnmarshalJSON

func (m *ConcurrentHashMap[K, V]) UnmarshalJSON(data []byte) error

func (*ConcurrentHashMap[K, V]) Values

func (m *ConcurrentHashMap[K, V]) Values() Collection[V]

type ConcurrentMap

type ConcurrentMap[K comparable, V any] interface {
	Map[K, V]
}

ConcurrentMap 线程安全的 Map

type ConcurrentModificationException

type ConcurrentModificationException struct {
	lang.BaseRuntimeException
}

ConcurrentModificationException 对应 java.util.ConcurrentModificationException

func NewConcurrentModificationException

func NewConcurrentModificationException(message string) *ConcurrentModificationException

type ConcurrentTreeMap

type ConcurrentTreeMap[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

func NewConcurrentTreeMap

func NewConcurrentTreeMap[K cmp.Ordered, V any]() *ConcurrentTreeMap[K, V]

func (*ConcurrentTreeMap[K, V]) CeilingEntry

func (m *ConcurrentTreeMap[K, V]) CeilingEntry(key K) (K, V, bool)

func (*ConcurrentTreeMap[K, V]) Clear

func (m *ConcurrentTreeMap[K, V]) Clear()

func (*ConcurrentTreeMap[K, V]) Compute

func (m *ConcurrentTreeMap[K, V]) Compute(key K, remappingFunction func(K, V) V) V

func (*ConcurrentTreeMap[K, V]) ComputeIfAbsent

func (m *ConcurrentTreeMap[K, V]) ComputeIfAbsent(key K, mappingFunction func(K) V) V

func (*ConcurrentTreeMap[K, V]) ComputeIfPresent

func (m *ConcurrentTreeMap[K, V]) ComputeIfPresent(key K, remappingFunction func(K, V) V) V

func (*ConcurrentTreeMap[K, V]) ContainsKey

func (m *ConcurrentTreeMap[K, V]) ContainsKey(key K) bool

func (*ConcurrentTreeMap[K, V]) ContainsValue

func (m *ConcurrentTreeMap[K, V]) ContainsValue(value V) bool

func (*ConcurrentTreeMap[K, V]) EntrySet

func (m *ConcurrentTreeMap[K, V]) EntrySet() Set[Entry[K, V]]

func (*ConcurrentTreeMap[K, V]) FirstEntry

func (m *ConcurrentTreeMap[K, V]) FirstEntry() (K, V, bool)

func (*ConcurrentTreeMap[K, V]) FirstKey

func (m *ConcurrentTreeMap[K, V]) FirstKey() K

func (*ConcurrentTreeMap[K, V]) FloorEntry

func (m *ConcurrentTreeMap[K, V]) FloorEntry(key K) (K, V, bool)

func (*ConcurrentTreeMap[K, V]) ForEach

func (m *ConcurrentTreeMap[K, V]) ForEach(action func(K, V))

func (*ConcurrentTreeMap[K, V]) Get

func (m *ConcurrentTreeMap[K, V]) Get(key K) V

func (*ConcurrentTreeMap[K, V]) GetFound

func (m *ConcurrentTreeMap[K, V]) GetFound(key K) (V, bool)

GetFound v2 Logic (Unrolled + Hybrid Access)

func (*ConcurrentTreeMap[K, V]) GetOrDefault

func (m *ConcurrentTreeMap[K, V]) GetOrDefault(key K, defaultValue V) V

func (*ConcurrentTreeMap[K, V]) HigherEntry

func (m *ConcurrentTreeMap[K, V]) HigherEntry(key K) (K, V, bool)

func (*ConcurrentTreeMap[K, V]) IsEmpty

func (m *ConcurrentTreeMap[K, V]) IsEmpty() bool

func (*ConcurrentTreeMap[K, V]) Keys

func (m *ConcurrentTreeMap[K, V]) Keys() Set[K]

func (*ConcurrentTreeMap[K, V]) LastEntry

func (m *ConcurrentTreeMap[K, V]) LastEntry() (K, V, bool)

func (*ConcurrentTreeMap[K, V]) LastKey

func (m *ConcurrentTreeMap[K, V]) LastKey() K

func (*ConcurrentTreeMap[K, V]) LowerEntry

func (m *ConcurrentTreeMap[K, V]) LowerEntry(key K) (K, V, bool)

func (*ConcurrentTreeMap[K, V]) MarshalJSON

func (m *ConcurrentTreeMap[K, V]) MarshalJSON() ([]byte, error)

func (*ConcurrentTreeMap[K, V]) Merge

func (m *ConcurrentTreeMap[K, V]) Merge(key K, value V, remappingFunction func(oldV, newV V) V) V

func (*ConcurrentTreeMap[K, V]) PollFirstEntry

func (m *ConcurrentTreeMap[K, V]) PollFirstEntry() (K, V, bool)

func (*ConcurrentTreeMap[K, V]) PollLastEntry

func (m *ConcurrentTreeMap[K, V]) PollLastEntry() (K, V, bool)

func (*ConcurrentTreeMap[K, V]) Put

func (m *ConcurrentTreeMap[K, V]) Put(key K, value V)

func (*ConcurrentTreeMap[K, V]) PutAll

func (m *ConcurrentTreeMap[K, V]) PutAll(other Map[K, V])

func (*ConcurrentTreeMap[K, V]) PutIfAbsent

func (m *ConcurrentTreeMap[K, V]) PutIfAbsent(key K, value V) V

func (*ConcurrentTreeMap[K, V]) Remove

func (m *ConcurrentTreeMap[K, V]) Remove(key K) bool

func (*ConcurrentTreeMap[K, V]) RemoveEntry

func (m *ConcurrentTreeMap[K, V]) RemoveEntry(key K, value V) bool

func (*ConcurrentTreeMap[K, V]) Replace

func (m *ConcurrentTreeMap[K, V]) Replace(key K, oldValue V, newValue V) bool

func (*ConcurrentTreeMap[K, V]) ReplaceAll

func (m *ConcurrentTreeMap[K, V]) ReplaceAll(function func(K, V) V)

func (*ConcurrentTreeMap[K, V]) Size

func (m *ConcurrentTreeMap[K, V]) Size() int

func (*ConcurrentTreeMap[K, V]) UnmarshalJSON

func (m *ConcurrentTreeMap[K, V]) UnmarshalJSON(data []byte) error

func (*ConcurrentTreeMap[K, V]) Values

func (m *ConcurrentTreeMap[K, V]) Values() Collection[V]

type DelayQueue

type DelayQueue[E Delayed] struct {
	// contains filtered or unexported fields
}

DelayQueue v4: Optimized & Stable

func NewDelayQueue

func NewDelayQueue[E Delayed]() *DelayQueue[E]

func NewDelayQueueCapacity

func NewDelayQueueCapacity[E Delayed](capacity int) *DelayQueue[E]

func (*DelayQueue[E]) Add

func (q *DelayQueue[E]) Add(e E) bool

--- Unsupported ---

func (*DelayQueue[E]) AddAll

func (q *DelayQueue[E]) AddAll(c Collection[E]) bool

func (*DelayQueue[E]) All

func (q *DelayQueue[E]) All() iter.Seq[E]

func (*DelayQueue[E]) Clear

func (q *DelayQueue[E]) Clear()

func (*DelayQueue[E]) Contains

func (q *DelayQueue[E]) Contains(e E) bool

func (*DelayQueue[E]) ContainsAll

func (q *DelayQueue[E]) ContainsAll(c Collection[E]) bool

func (*DelayQueue[E]) DrainTo

func (q *DelayQueue[E]) DrainTo(c Collection[E]) int

func (*DelayQueue[E]) DrainToN

func (q *DelayQueue[E]) DrainToN(c Collection[E], max int) int

func (*DelayQueue[E]) Element

func (q *DelayQueue[E]) Element() E

func (*DelayQueue[E]) IsEmpty

func (q *DelayQueue[E]) IsEmpty() bool

func (*DelayQueue[E]) Offer

func (q *DelayQueue[E]) Offer(e E) bool

func (*DelayQueue[E]) OfferTimeout

func (q *DelayQueue[E]) OfferTimeout(e E, timeout time.Duration) bool

func (*DelayQueue[E]) Peek

func (q *DelayQueue[E]) Peek() (E, bool)

func (*DelayQueue[E]) Poll

func (q *DelayQueue[E]) Poll() (E, bool)

func (*DelayQueue[E]) PollTimeout

func (q *DelayQueue[E]) PollTimeout(timeout time.Duration) (E, bool)

func (*DelayQueue[E]) Put

func (q *DelayQueue[E]) Put(e E)

func (*DelayQueue[E]) RemainingCapacity

func (q *DelayQueue[E]) RemainingCapacity() int

func (*DelayQueue[E]) Remove

func (q *DelayQueue[E]) Remove(e E) bool

func (*DelayQueue[E]) RemoveAll

func (q *DelayQueue[E]) RemoveAll(c Collection[E]) bool

func (*DelayQueue[E]) RemoveHead

func (q *DelayQueue[E]) RemoveHead() E

func (*DelayQueue[E]) RetainAll

func (q *DelayQueue[E]) RetainAll(c Collection[E]) bool

func (*DelayQueue[E]) Size

func (q *DelayQueue[E]) Size() int

func (*DelayQueue[E]) Take

func (q *DelayQueue[E]) Take() E

Take v4: 移除激进的自旋,回归高效的 Timer 调度

func (*DelayQueue[E]) ToSlice

func (q *DelayQueue[E]) ToSlice() []E

type Delayed

type Delayed interface {
	// CompareTo 用于排序。返回负数表示 self < other (优先级更高),0 表示相等,正数表示 self > other
	CompareTo(other Delayed) int

	// Delay 返回剩余的延迟时间。如果 <= 0 表示已过期,可以被立即取出。
	Delay() time.Duration
}

Delayed 混合了排序和延迟特性的接口 对标 java.util.concurrent.Delayed

type Deque

type Deque[E any] interface {
	Queue[E]
	SequencedCollection[E]

	// --- 队头操作 ---
	OfferFirst(e E) bool
	PollFirst() (E, bool)
	PeekFirst() (E, bool)

	// --- 队尾操作 ---
	OfferLast(e E) bool
	PollLast() (E, bool)
	PeekLast() (E, bool)

	// --- 栈操作 ---
	Push(e E)
	Pop() E

	// --- 杂项 ---
	RemoveFirstOccurrence(o E) bool
	RemoveLastOccurrence(o E) bool
	DescendingIterator() Iterator[E] // Java style
	DescendingAll() iter.Seq[E]      // Go style iterator
}

Deque 双端队列接口 (完全对标 java.util.Deque)

type Entry

type Entry[K comparable, V any] struct {
	Key   K
	Value V
}

type HashMap

type HashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

HashMap 封装 Go 原生 map

func NewHashMap

func NewHashMap[K comparable, V any](initialCapacity ...int) *HashMap[K, V]

func NewHashMapFrom

func NewHashMapFrom[K comparable, V any](source map[K]V) *HashMap[K, V]

func (*HashMap[K, V]) All

func (h *HashMap[K, V]) All() iter.Seq2[K, V]

func (*HashMap[K, V]) Clear

func (h *HashMap[K, V]) Clear()

func (*HashMap[K, V]) Clone

func (h *HashMap[K, V]) Clone() *HashMap[K, V]

func (*HashMap[K, V]) Compute

func (h *HashMap[K, V]) Compute(key K, remappingFunction func(K, V) V) V

func (*HashMap[K, V]) ComputeIfAbsent

func (h *HashMap[K, V]) ComputeIfAbsent(key K, mappingFunction func(K) V) V

func (*HashMap[K, V]) ComputeIfPresent

func (h *HashMap[K, V]) ComputeIfPresent(key K, remappingFunction func(K, V) V) V

func (*HashMap[K, V]) ContainsKey

func (h *HashMap[K, V]) ContainsKey(key K) bool

func (*HashMap[K, V]) ContainsValue

func (h *HashMap[K, V]) ContainsValue(value V) bool

func (*HashMap[K, V]) EntrySet

func (h *HashMap[K, V]) EntrySet() Set[Entry[K, V]]

func (*HashMap[K, V]) ForEach

func (h *HashMap[K, V]) ForEach(action func(K, V))

func (*HashMap[K, V]) Get

func (h *HashMap[K, V]) Get(key K) V

func (*HashMap[K, V]) GetFound

func (h *HashMap[K, V]) GetFound(key K) (V, bool)

func (*HashMap[K, V]) GetOrDefault

func (h *HashMap[K, V]) GetOrDefault(key K, defaultValue V) V

func (*HashMap[K, V]) IsEmpty

func (h *HashMap[K, V]) IsEmpty() bool

func (*HashMap[K, V]) Keys

func (h *HashMap[K, V]) Keys() Set[K]

func (*HashMap[K, V]) MarshalJSON

func (h *HashMap[K, V]) MarshalJSON() ([]byte, error)

func (*HashMap[K, V]) Merge

func (h *HashMap[K, V]) Merge(key K, value V, remappingFunction func(oldV, newV V) V) V

func (*HashMap[K, V]) Put

func (h *HashMap[K, V]) Put(key K, value V)

func (*HashMap[K, V]) PutAll

func (h *HashMap[K, V]) PutAll(other Map[K, V])

func (*HashMap[K, V]) PutIfAbsent

func (h *HashMap[K, V]) PutIfAbsent(key K, value V) V

func (*HashMap[K, V]) Remove

func (h *HashMap[K, V]) Remove(key K) bool

func (*HashMap[K, V]) RemoveEntry

func (h *HashMap[K, V]) RemoveEntry(key K, value V) bool

func (*HashMap[K, V]) Replace

func (h *HashMap[K, V]) Replace(key K, oldValue V, newValue V) bool

func (*HashMap[K, V]) ReplaceAll

func (h *HashMap[K, V]) ReplaceAll(function func(K, V) V)

func (*HashMap[K, V]) Size

func (h *HashMap[K, V]) Size() int

func (*HashMap[K, V]) String

func (h *HashMap[K, V]) String() string

func (*HashMap[K, V]) UnmarshalJSON

func (h *HashMap[K, V]) UnmarshalJSON(data []byte) error

func (*HashMap[K, V]) Values

func (h *HashMap[K, V]) Values() Collection[V]

type HashSet

type HashSet[E comparable] struct {
	// contains filtered or unexported fields
}

HashSet 基于 HashMap 实现的高性能集合 优化等级: Ultimate (Direct Map Access, maps.Copy, Type Assertions)

func NewHashSet

func NewHashSet[E comparable](initialCapacity ...int) *HashSet[E]

func NewHashSetFrom

func NewHashSetFrom[E comparable](elements ...E) *HashSet[E]

func (*HashSet[E]) Add

func (s *HashSet[E]) Add(e E) bool

Add 极致优化:直接操作底层 map,无函数调用

func (*HashSet[E]) AddAll

func (s *HashSet[E]) AddAll(c Collection[E]) bool

func (*HashSet[E]) All

func (s *HashSet[E]) All() iter.Seq[E]

func (*HashSet[E]) Clear

func (s *HashSet[E]) Clear()

func (*HashSet[E]) Clone

func (s *HashSet[E]) Clone() *HashSet[E]

func (*HashSet[E]) Contains

func (s *HashSet[E]) Contains(e E) bool

func (*HashSet[E]) ContainsAll

func (s *HashSet[E]) ContainsAll(c Collection[E]) bool

func (*HashSet[E]) IsEmpty

func (s *HashSet[E]) IsEmpty() bool

func (*HashSet[E]) MarshalJSON

func (s *HashSet[E]) MarshalJSON() ([]byte, error)

func (*HashSet[E]) Remove

func (s *HashSet[E]) Remove(e E) bool

Remove 极致优化

func (*HashSet[E]) RemoveAll

func (s *HashSet[E]) RemoveAll(c Collection[E]) bool

func (*HashSet[E]) RetainAll

func (s *HashSet[E]) RetainAll(c Collection[E]) bool

RetainAll 零分配优化

func (*HashSet[E]) Size

func (s *HashSet[E]) Size() int

func (*HashSet[E]) String

func (s *HashSet[E]) String() string

func (*HashSet[E]) ToSlice

func (s *HashSet[E]) ToSlice() []E

func (*HashSet[E]) UnmarshalJSON

func (s *HashSet[E]) UnmarshalJSON(data []byte) error

type InputMismatchException

type InputMismatchException struct {
	NoSuchElementException
}

InputMismatchException 对应 java.util.InputMismatchException

func NewInputMismatchException

func NewInputMismatchException(message string) *InputMismatchException

type Iterator

type Iterator[E any] interface {
	HasNext() bool
	Next() E
	Remove()
}

Iterator 迭代器接口

type LinkedBlockingDeque

type LinkedBlockingDeque[E any] struct {
	// contains filtered or unexported fields
}

LinkedBlockingDeque 基于链表的双端阻塞队列 v2 (Cache-Optimized)

性能说明 v2: 1. Cache Padding: 强制隔离锁、数据头尾、信号量,消除多核 CPU 下的伪共享 (False Sharing)。 2. Manual Unlocking: 移除热点路径的 defer,减少运行时开销。 3. Hybrid Spin: 结合指令空转与 Gosched,在极低延迟与调度友好之间取得平衡。

func NewLinkedBlockingDeque

func NewLinkedBlockingDeque[E any](capacity int) *LinkedBlockingDeque[E]

func (*LinkedBlockingDeque[E]) Add

func (q *LinkedBlockingDeque[E]) Add(e E) bool

func (*LinkedBlockingDeque[E]) AddAll

func (q *LinkedBlockingDeque[E]) AddAll(c Collection[E]) bool

func (*LinkedBlockingDeque[E]) AddFirst

func (q *LinkedBlockingDeque[E]) AddFirst(e E)

func (*LinkedBlockingDeque[E]) AddLast

func (q *LinkedBlockingDeque[E]) AddLast(e E)

func (*LinkedBlockingDeque[E]) All

func (q *LinkedBlockingDeque[E]) All() iter.Seq[E]

func (*LinkedBlockingDeque[E]) Clear

func (q *LinkedBlockingDeque[E]) Clear()

func (*LinkedBlockingDeque[E]) Contains

func (q *LinkedBlockingDeque[E]) Contains(e E) bool

func (*LinkedBlockingDeque[E]) ContainsAll

func (q *LinkedBlockingDeque[E]) ContainsAll(c Collection[E]) bool

func (*LinkedBlockingDeque[E]) DrainTo

func (q *LinkedBlockingDeque[E]) DrainTo(c Collection[E]) int

func (*LinkedBlockingDeque[E]) DrainToN

func (q *LinkedBlockingDeque[E]) DrainToN(c Collection[E], maxElements int) int

func (*LinkedBlockingDeque[E]) Element

func (q *LinkedBlockingDeque[E]) Element() E

func (*LinkedBlockingDeque[E]) IsEmpty

func (q *LinkedBlockingDeque[E]) IsEmpty() bool

func (*LinkedBlockingDeque[E]) Offer

func (q *LinkedBlockingDeque[E]) Offer(e E) bool

func (*LinkedBlockingDeque[E]) OfferFirst

func (q *LinkedBlockingDeque[E]) OfferFirst(e E) bool

func (*LinkedBlockingDeque[E]) OfferFirstTimeout

func (q *LinkedBlockingDeque[E]) OfferFirstTimeout(e E, timeout time.Duration) bool

func (*LinkedBlockingDeque[E]) OfferLast

func (q *LinkedBlockingDeque[E]) OfferLast(e E) bool

func (*LinkedBlockingDeque[E]) OfferLastTimeout

func (q *LinkedBlockingDeque[E]) OfferLastTimeout(e E, timeout time.Duration) bool

func (*LinkedBlockingDeque[E]) Peek

func (q *LinkedBlockingDeque[E]) Peek() (E, bool)

func (*LinkedBlockingDeque[E]) PeekFirst

func (q *LinkedBlockingDeque[E]) PeekFirst() (E, bool)

func (*LinkedBlockingDeque[E]) PeekLast

func (q *LinkedBlockingDeque[E]) PeekLast() (E, bool)

func (*LinkedBlockingDeque[E]) Poll

func (q *LinkedBlockingDeque[E]) Poll() (E, bool)

func (*LinkedBlockingDeque[E]) PollFirst

func (q *LinkedBlockingDeque[E]) PollFirst() (E, bool)

func (*LinkedBlockingDeque[E]) PollFirstTimeout

func (q *LinkedBlockingDeque[E]) PollFirstTimeout(timeout time.Duration) (E, bool)

func (*LinkedBlockingDeque[E]) PollLast

func (q *LinkedBlockingDeque[E]) PollLast() (E, bool)

func (*LinkedBlockingDeque[E]) PollLastTimeout

func (q *LinkedBlockingDeque[E]) PollLastTimeout(timeout time.Duration) (E, bool)

func (*LinkedBlockingDeque[E]) Put

func (q *LinkedBlockingDeque[E]) Put(e E)

func (*LinkedBlockingDeque[E]) PutFirst

func (q *LinkedBlockingDeque[E]) PutFirst(e E)

func (*LinkedBlockingDeque[E]) PutLast

func (q *LinkedBlockingDeque[E]) PutLast(e E)

func (*LinkedBlockingDeque[E]) RemainingCapacity

func (q *LinkedBlockingDeque[E]) RemainingCapacity() int

func (*LinkedBlockingDeque[E]) Remove

func (q *LinkedBlockingDeque[E]) Remove(e E) bool

func (*LinkedBlockingDeque[E]) RemoveAll

func (q *LinkedBlockingDeque[E]) RemoveAll(c Collection[E]) bool

func (*LinkedBlockingDeque[E]) RemoveHead

func (q *LinkedBlockingDeque[E]) RemoveHead() E

func (*LinkedBlockingDeque[E]) RetainAll

func (q *LinkedBlockingDeque[E]) RetainAll(c Collection[E]) bool

func (*LinkedBlockingDeque[E]) Size

func (q *LinkedBlockingDeque[E]) Size() int

func (*LinkedBlockingDeque[E]) Take

func (q *LinkedBlockingDeque[E]) Take() E

func (*LinkedBlockingDeque[E]) TakeFirst

func (q *LinkedBlockingDeque[E]) TakeFirst() E

func (*LinkedBlockingDeque[E]) TakeLast

func (q *LinkedBlockingDeque[E]) TakeLast() E

func (*LinkedBlockingDeque[E]) ToSlice

func (q *LinkedBlockingDeque[E]) ToSlice() []E

type LinkedBlockingQueue

type LinkedBlockingQueue[E any] struct {
	// contains filtered or unexported fields
}

LinkedBlockingQueue v5: Compact Node + Isolated Locks

func NewLinkedBlockingQueue

func NewLinkedBlockingQueue[E any]() *LinkedBlockingQueue[E]

func NewLinkedBlockingQueueCapacity

func NewLinkedBlockingQueueCapacity[E any](capacity int) *LinkedBlockingQueue[E]

func (*LinkedBlockingQueue[E]) Add

func (q *LinkedBlockingQueue[E]) Add(e E) bool

func (*LinkedBlockingQueue[E]) AddAll

func (q *LinkedBlockingQueue[E]) AddAll(c Collection[E]) bool

func (*LinkedBlockingQueue[E]) All

func (q *LinkedBlockingQueue[E]) All() iter.Seq[E]

func (*LinkedBlockingQueue[E]) Clear

func (q *LinkedBlockingQueue[E]) Clear()

func (*LinkedBlockingQueue[E]) Contains

func (q *LinkedBlockingQueue[E]) Contains(o E) bool

func (*LinkedBlockingQueue[E]) ContainsAll

func (q *LinkedBlockingQueue[E]) ContainsAll(c Collection[E]) bool

--- Unsupported ---

func (*LinkedBlockingQueue[E]) DrainTo

func (q *LinkedBlockingQueue[E]) DrainTo(c Collection[E]) int

func (*LinkedBlockingQueue[E]) DrainToN

func (q *LinkedBlockingQueue[E]) DrainToN(c Collection[E], maxElements int) int

func (*LinkedBlockingQueue[E]) Element

func (q *LinkedBlockingQueue[E]) Element() E

func (*LinkedBlockingQueue[E]) IsEmpty

func (q *LinkedBlockingQueue[E]) IsEmpty() bool

func (*LinkedBlockingQueue[E]) Offer

func (q *LinkedBlockingQueue[E]) Offer(e E) bool

func (*LinkedBlockingQueue[E]) OfferTimeout

func (q *LinkedBlockingQueue[E]) OfferTimeout(e E, timeout time.Duration) bool

func (*LinkedBlockingQueue[E]) Peek

func (q *LinkedBlockingQueue[E]) Peek() (E, bool)

func (*LinkedBlockingQueue[E]) Poll

func (q *LinkedBlockingQueue[E]) Poll() (E, bool)

func (*LinkedBlockingQueue[E]) PollTimeout

func (q *LinkedBlockingQueue[E]) PollTimeout(timeout time.Duration) (E, bool)

func (*LinkedBlockingQueue[E]) Put

func (q *LinkedBlockingQueue[E]) Put(e E)

func (*LinkedBlockingQueue[E]) RemainingCapacity

func (q *LinkedBlockingQueue[E]) RemainingCapacity() int

func (*LinkedBlockingQueue[E]) Remove

func (q *LinkedBlockingQueue[E]) Remove(o E) bool

func (*LinkedBlockingQueue[E]) RemoveAll

func (q *LinkedBlockingQueue[E]) RemoveAll(c Collection[E]) bool

func (*LinkedBlockingQueue[E]) RemoveHead

func (q *LinkedBlockingQueue[E]) RemoveHead() E

func (*LinkedBlockingQueue[E]) RetainAll

func (q *LinkedBlockingQueue[E]) RetainAll(c Collection[E]) bool

func (*LinkedBlockingQueue[E]) Size

func (q *LinkedBlockingQueue[E]) Size() int

func (*LinkedBlockingQueue[E]) Take

func (q *LinkedBlockingQueue[E]) Take() E

func (*LinkedBlockingQueue[E]) ToSlice

func (q *LinkedBlockingQueue[E]) ToSlice() []E

type LinkedHashMap

type LinkedHashMap[K comparable, V any] struct {
	RemoveEldestEntry func(Entry[K, V]) bool
	// contains filtered or unexported fields
}

LinkedHashMap 优化等级: Physical Limit (Eager Alloc + Full Inlining + Register Reuse)

func NewLinkedHashMap

func NewLinkedHashMap[K comparable, V any](initialCapacity ...int) *LinkedHashMap[K, V]

func NewLruCache

func NewLruCache[K comparable, V any](capacity int, maxEntries int) *LinkedHashMap[K, V]

func (*LinkedHashMap[K, V]) Clear

func (m *LinkedHashMap[K, V]) Clear()

Clear 物理极限清理

func (*LinkedHashMap[K, V]) Compute

func (m *LinkedHashMap[K, V]) Compute(key K, remappingFunction func(K, V) V) V

func (*LinkedHashMap[K, V]) ComputeIfAbsent

func (m *LinkedHashMap[K, V]) ComputeIfAbsent(key K, mappingFunction func(K) V) V

func (*LinkedHashMap[K, V]) ComputeIfPresent

func (m *LinkedHashMap[K, V]) ComputeIfPresent(key K, remappingFunction func(K, V) V) V

func (*LinkedHashMap[K, V]) ContainsKey

func (m *LinkedHashMap[K, V]) ContainsKey(key K) bool

func (*LinkedHashMap[K, V]) ContainsValue

func (m *LinkedHashMap[K, V]) ContainsValue(value V) bool

func (*LinkedHashMap[K, V]) EntrySet

func (m *LinkedHashMap[K, V]) EntrySet() Set[Entry[K, V]]

func (*LinkedHashMap[K, V]) ForEach

func (m *LinkedHashMap[K, V]) ForEach(action func(K, V))

func (*LinkedHashMap[K, V]) Get

func (m *LinkedHashMap[K, V]) Get(key K) V

Get 极速读取 优化: 保持简单,确保编译器内联

func (*LinkedHashMap[K, V]) GetFound

func (m *LinkedHashMap[K, V]) GetFound(key K) (V, bool)

func (*LinkedHashMap[K, V]) GetOrDefault

func (m *LinkedHashMap[K, V]) GetOrDefault(key K, defaultValue V) V

func (*LinkedHashMap[K, V]) IsEmpty

func (m *LinkedHashMap[K, V]) IsEmpty() bool

func (*LinkedHashMap[K, V]) Keys

func (m *LinkedHashMap[K, V]) Keys() Set[K]

func (*LinkedHashMap[K, V]) MarshalJSON

func (m *LinkedHashMap[K, V]) MarshalJSON() ([]byte, error)

func (*LinkedHashMap[K, V]) Merge

func (m *LinkedHashMap[K, V]) Merge(key K, value V, remappingFunction func(oldV, newV V) V) V

func (*LinkedHashMap[K, V]) Put

func (m *LinkedHashMap[K, V]) Put(key K, value V)

Put 物理极限写入 优化: 彻底内联 newNode, linkNode, moveNodeToTail 逻辑

func (*LinkedHashMap[K, V]) PutAll

func (m *LinkedHashMap[K, V]) PutAll(other Map[K, V])

func (*LinkedHashMap[K, V]) PutIfAbsent

func (m *LinkedHashMap[K, V]) PutIfAbsent(key K, value V) V

func (*LinkedHashMap[K, V]) Remove

func (m *LinkedHashMap[K, V]) Remove(key K) bool

Remove 极速删除

func (*LinkedHashMap[K, V]) RemoveEntry

func (m *LinkedHashMap[K, V]) RemoveEntry(key K, value V) bool

func (*LinkedHashMap[K, V]) Replace

func (m *LinkedHashMap[K, V]) Replace(key K, oldValue V, newValue V) bool

func (*LinkedHashMap[K, V]) ReplaceAll

func (m *LinkedHashMap[K, V]) ReplaceAll(function func(K, V) V)

func (*LinkedHashMap[K, V]) Size

func (m *LinkedHashMap[K, V]) Size() int

func (*LinkedHashMap[K, V]) String

func (m *LinkedHashMap[K, V]) String() string

func (*LinkedHashMap[K, V]) UnmarshalJSON

func (m *LinkedHashMap[K, V]) UnmarshalJSON(data []byte) error

func (*LinkedHashMap[K, V]) Values

func (m *LinkedHashMap[K, V]) Values() Collection[V]

type LinkedHashSet

type LinkedHashSet[E comparable] struct {
	// contains filtered or unexported fields
}

LinkedHashSet 保持插入顺序的哈希集合 优化等级: Physical Limit (Block Alloc + Native Map + Flash Clear + BCE + Lazy Init)

func NewLinkedHashSet

func NewLinkedHashSet[E comparable](initialCapacity ...int) *LinkedHashSet[E]

func NewLinkedHashSetFrom

func NewLinkedHashSetFrom[E comparable](c Collection[E]) *LinkedHashSet[E]

func (*LinkedHashSet[E]) Add

func (s *LinkedHashSet[E]) Add(e E) bool

Add 实现 Set 语义 优化: 手动内联 newNode 的热路径,减少函数调用开销

func (*LinkedHashSet[E]) AddAll

func (s *LinkedHashSet[E]) AddAll(c Collection[E]) bool

func (*LinkedHashSet[E]) AddFirst

func (s *LinkedHashSet[E]) AddFirst(e E)

func (*LinkedHashSet[E]) AddLast

func (s *LinkedHashSet[E]) AddLast(e E)

func (*LinkedHashSet[E]) All

func (s *LinkedHashSet[E]) All() iter.Seq[E]

All 原生迭代器 (Go 1.23)

func (*LinkedHashSet[E]) Clear

func (s *LinkedHashSet[E]) Clear()

Clear 物理极限清空 (Flash Clear)

func (*LinkedHashSet[E]) Contains

func (s *LinkedHashSet[E]) Contains(e E) bool

func (*LinkedHashSet[E]) ContainsAll

func (s *LinkedHashSet[E]) ContainsAll(c Collection[E]) bool

func (*LinkedHashSet[E]) GetFirst

func (s *LinkedHashSet[E]) GetFirst() E

func (*LinkedHashSet[E]) GetLast

func (s *LinkedHashSet[E]) GetLast() E

func (*LinkedHashSet[E]) IsEmpty

func (s *LinkedHashSet[E]) IsEmpty() bool

func (*LinkedHashSet[E]) MarshalJSON

func (s *LinkedHashSet[E]) MarshalJSON() ([]byte, error)

func (*LinkedHashSet[E]) Remove

func (s *LinkedHashSet[E]) Remove(e E) bool

func (*LinkedHashSet[E]) RemoveAll

func (s *LinkedHashSet[E]) RemoveAll(c Collection[E]) bool

func (*LinkedHashSet[E]) RemoveFirst

func (s *LinkedHashSet[E]) RemoveFirst() E

func (*LinkedHashSet[E]) RemoveLast

func (s *LinkedHashSet[E]) RemoveLast() E

func (*LinkedHashSet[E]) RetainAll

func (s *LinkedHashSet[E]) RetainAll(c Collection[E]) bool

func (*LinkedHashSet[E]) Reversed

func (s *LinkedHashSet[E]) Reversed() []E

func (*LinkedHashSet[E]) Size

func (s *LinkedHashSet[E]) Size() int

func (*LinkedHashSet[E]) String

func (s *LinkedHashSet[E]) String() string

func (*LinkedHashSet[E]) ToSlice

func (s *LinkedHashSet[E]) ToSlice() []E

ToSlice 按插入顺序返回切片

func (*LinkedHashSet[E]) UnmarshalJSON

func (s *LinkedHashSet[E]) UnmarshalJSON(data []byte) error

UnmarshalJSON 修复了空 Map Panic 的问题

type LinkedList

type LinkedList[E any] struct {
	// contains filtered or unexported fields
}

LinkedList 物理极限版

func NewLinkedList

func NewLinkedList[E any]() *LinkedList[E]

func NewLinkedListFromCollection

func NewLinkedListFromCollection[E any](c Collection[E]) *LinkedList[E]

func (*LinkedList[E]) Add

func (l *LinkedList[E]) Add(e E) bool

func (*LinkedList[E]) AddAll

func (l *LinkedList[E]) AddAll(c Collection[E]) bool

func (*LinkedList[E]) AddAllAtIndex

func (l *LinkedList[E]) AddAllAtIndex(index int, c Collection[E]) bool

func (*LinkedList[E]) AddAtIndex

func (l *LinkedList[E]) AddAtIndex(index int, element E)

func (*LinkedList[E]) AddFirst

func (l *LinkedList[E]) AddFirst(e E)

--- Deque 接口实现 ---

func (*LinkedList[E]) AddLast

func (l *LinkedList[E]) AddLast(e E)

func (*LinkedList[E]) All

func (l *LinkedList[E]) All() iter.Seq[E]

func (*LinkedList[E]) Clear

func (l *LinkedList[E]) Clear()

func (*LinkedList[E]) Contains

func (l *LinkedList[E]) Contains(o E) bool

func (*LinkedList[E]) ContainsAll

func (l *LinkedList[E]) ContainsAll(c Collection[E]) bool

func (*LinkedList[E]) Element

func (l *LinkedList[E]) Element() E

func (*LinkedList[E]) Get

func (l *LinkedList[E]) Get(index int) E

func (*LinkedList[E]) GetFirst

func (l *LinkedList[E]) GetFirst() E

func (*LinkedList[E]) GetLast

func (l *LinkedList[E]) GetLast() E

func (*LinkedList[E]) IndexOf

func (l *LinkedList[E]) IndexOf(o E) int

func (*LinkedList[E]) IsEmpty

func (l *LinkedList[E]) IsEmpty() bool

func (*LinkedList[E]) Iterator

func (l *LinkedList[E]) Iterator() Iterator[E]

func (*LinkedList[E]) LastIndexOf

func (l *LinkedList[E]) LastIndexOf(o E) int

func (*LinkedList[E]) ListIterator

func (l *LinkedList[E]) ListIterator() ListIterator[E]

func (*LinkedList[E]) ListIteratorAtIndex

func (l *LinkedList[E]) ListIteratorAtIndex(index int) ListIterator[E]

func (*LinkedList[E]) Offer

func (l *LinkedList[E]) Offer(e E) bool

func (*LinkedList[E]) OfferFirst

func (l *LinkedList[E]) OfferFirst(e E) bool

func (*LinkedList[E]) OfferLast

func (l *LinkedList[E]) OfferLast(e E) bool

func (*LinkedList[E]) Peek

func (l *LinkedList[E]) Peek() (E, bool)

func (*LinkedList[E]) PeekFirst

func (l *LinkedList[E]) PeekFirst() (E, bool)

func (*LinkedList[E]) PeekLast

func (l *LinkedList[E]) PeekLast() (E, bool)

func (*LinkedList[E]) Poll

func (l *LinkedList[E]) Poll() (E, bool)

func (*LinkedList[E]) PollFirst

func (l *LinkedList[E]) PollFirst() (E, bool)

func (*LinkedList[E]) PollLast

func (l *LinkedList[E]) PollLast() (E, bool)

func (*LinkedList[E]) Pop

func (l *LinkedList[E]) Pop() E

func (*LinkedList[E]) Push

func (l *LinkedList[E]) Push(e E)

func (*LinkedList[E]) Remove

func (l *LinkedList[E]) Remove(o E) bool

func (*LinkedList[E]) RemoveAll

func (l *LinkedList[E]) RemoveAll(c Collection[E]) bool

func (*LinkedList[E]) RemoveAtIndex

func (l *LinkedList[E]) RemoveAtIndex(index int) E

func (*LinkedList[E]) RemoveFirst

func (l *LinkedList[E]) RemoveFirst() E

func (*LinkedList[E]) RemoveFirstOccurrence

func (l *LinkedList[E]) RemoveFirstOccurrence(o E) bool

func (*LinkedList[E]) RemoveHead

func (l *LinkedList[E]) RemoveHead() E

func (*LinkedList[E]) RemoveLast

func (l *LinkedList[E]) RemoveLast() E

func (*LinkedList[E]) RemoveLastOccurrence

func (l *LinkedList[E]) RemoveLastOccurrence(o E) bool

func (*LinkedList[E]) RetainAll

func (l *LinkedList[E]) RetainAll(c Collection[E]) bool

func (*LinkedList[E]) Reversed

func (l *LinkedList[E]) Reversed() []E

func (*LinkedList[E]) Set

func (l *LinkedList[E]) Set(index int, element E) E

func (*LinkedList[E]) Size

func (l *LinkedList[E]) Size() int

func (*LinkedList[E]) ToSlice

func (l *LinkedList[E]) ToSlice() []E

type List

type List[E any] interface {
	SequencedCollection[E]

	Get(index int) E
	Set(index int, element E) E
	AddAtIndex(index int, element E)
	RemoveAtIndex(index int) E
	IndexOf(e E) int
	LastIndexOf(e E) int

	SubList(fromIndex, toIndex int) List[E]
	Sort(less func(a, b E) int)

	RemoveIf(filter func(E) bool) bool
	ReplaceAll(operator func(E) E)
	ForEach(action func(E))

	ListIterator() ListIterator[E]
}

List 列表接口

type ListIterator

type ListIterator[E any] interface {
	Iterator[E]
	HasPrevious() bool
	Previous() E
	NextIndex() int
	PreviousIndex() int
	Set(e E)
	Add(e E)
}

ListIterator 双向迭代器

type Map

type Map[K comparable, V any] interface {
	Size() int
	IsEmpty() bool
	ContainsKey(key K) bool
	ContainsValue(value V) bool
	Get(key K) V
	GetFound(key K) (V, bool)
	Put(key K, value V)
	Remove(key K) bool
	PutAll(m Map[K, V])
	Clear()
	Keys() Set[K]
	Values() Collection[V]
	EntrySet() Set[Entry[K, V]]
	GetOrDefault(key K, defaultValue V) V
	PutIfAbsent(key K, value V) V
	RemoveEntry(key K, value V) bool
	Replace(key K, oldValue V, newValue V) bool
	ReplaceAll(function func(K, V) V)
	ComputeIfAbsent(key K, mappingFunction func(K) V) V
	ComputeIfPresent(key K, remappingFunction func(K, V) V) V
	Compute(key K, remappingFunction func(K, V) V) V
	Merge(key K, value V, remappingFunction func(oldV, newV V) V) V
	ForEach(action func(K, V))
}

Map 映射接口

type NavigableMap[K cmp.Ordered, V any] interface {
	SortedMap[K, V]
	LowerEntry(key K) (K, V, bool)
	FloorEntry(key K) (K, V, bool)
	CeilingEntry(key K) (K, V, bool)
	HigherEntry(key K) (K, V, bool)
	FirstEntry() (K, V, bool)
	LastEntry() (K, V, bool)
	PollFirstEntry() (K, V, bool)
	PollLastEntry() (K, V, bool)
}

type NoSuchElementException

type NoSuchElementException struct {
	lang.BaseRuntimeException
}

NoSuchElementException 对应 java.util.NoSuchElementException

func NewNoSuchElementException

func NewNoSuchElementException(message string) *NoSuchElementException

type PriorityQueue

type PriorityQueue[E any] struct {
	// contains filtered or unexported fields
}

PriorityQueue 基于二叉堆(Binary Heap)的物理极限优先队列 优化等级: Physical Limit (Manual Inline + Batch Heapify + Zero Alloc)

func NewPriorityQueue

func NewPriorityQueue[E any](comparator Comparator[E], initialCapacity ...int) *PriorityQueue[E]

func NewPriorityQueueOf

func NewPriorityQueueOf[E any](comparator Comparator[E], elements ...E) *PriorityQueue[E]

NewPriorityQueueOf O(N) 极速建堆 (Floyd's Algorithm)

func (*PriorityQueue[E]) Add

func (q *PriorityQueue[E]) Add(e E) bool

Add 实现 (Manual Inline siftUp)

func (*PriorityQueue[E]) AddAll

func (q *PriorityQueue[E]) AddAll(c Collection[E]) bool

AddAll O(N+M) 批量添加 优化: 先 Append 后 Heapify,快于循环 Add (O(M log N))

func (*PriorityQueue[E]) All

func (q *PriorityQueue[E]) All() iter.Seq[E]

func (*PriorityQueue[E]) Clear

func (q *PriorityQueue[E]) Clear()

func (*PriorityQueue[E]) Contains

func (q *PriorityQueue[E]) Contains(e E) bool

func (*PriorityQueue[E]) ContainsAll

func (q *PriorityQueue[E]) ContainsAll(c Collection[E]) bool

func (*PriorityQueue[E]) Element

func (q *PriorityQueue[E]) Element() E

func (*PriorityQueue[E]) IndexOf

func (q *PriorityQueue[E]) IndexOf(o E) int

func (*PriorityQueue[E]) IsEmpty

func (q *PriorityQueue[E]) IsEmpty() bool

func (*PriorityQueue[E]) MarshalJSON

func (q *PriorityQueue[E]) MarshalJSON() ([]byte, error)

func (*PriorityQueue[E]) Offer

func (q *PriorityQueue[E]) Offer(e E) bool

Offer 实现 (Manual Inline siftUp) 极速入队: 消除函数调用开销

func (*PriorityQueue[E]) Peek

func (q *PriorityQueue[E]) Peek() (E, bool)

func (*PriorityQueue[E]) Poll

func (q *PriorityQueue[E]) Poll() (E, bool)

Poll 实现 (Manual Inline siftDown) 极速出队: 消除函数调用开销

func (*PriorityQueue[E]) Remove

func (q *PriorityQueue[E]) Remove(o E) bool

func (*PriorityQueue[E]) RemoveAll

func (q *PriorityQueue[E]) RemoveAll(c Collection[E]) bool

RemoveAll O(N * Cost(Contains)) 优化: 原地过滤 + 重建,避免 O(M*N) 的线性查找开销

func (*PriorityQueue[E]) RemoveHead

func (q *PriorityQueue[E]) RemoveHead() E

func (*PriorityQueue[E]) RemoveIf

func (q *PriorityQueue[E]) RemoveIf(filter func(E) bool) bool

RemoveIf Java 8+ 接口

func (*PriorityQueue[E]) RetainAll

func (q *PriorityQueue[E]) RetainAll(c Collection[E]) bool

RetainAll O(N * Cost(Contains)) 优化: 原地过滤 + 重建

func (*PriorityQueue[E]) Size

func (q *PriorityQueue[E]) Size() int

func (*PriorityQueue[E]) String

func (q *PriorityQueue[E]) String() string

func (*PriorityQueue[E]) ToSlice

func (q *PriorityQueue[E]) ToSlice() []E

func (*PriorityQueue[E]) UnmarshalJSON

func (q *PriorityQueue[E]) UnmarshalJSON(data []byte) error

type Queue

type Queue[E any] interface {
	Collection[E]

	// --- 插入 ---
	Offer(e E) bool

	// --- 移除 ---
	Poll() (E, bool) // 返回 (value, true) 或 (zero, false)
	RemoveHead() E   // 移除并返回队头,为空时 Panic (对应 remove())

	// --- 检查 ---
	Peek() (E, bool) // 返回 (value, true) 或 (zero, false)
	Element() E      // 返回队头,为空时 Panic (对应 element())
}

Queue 队列接口 完全对标 java.util.Queue

type RandomAccess

type RandomAccess interface{}

RandomAccess 列表接口,用于标识是否支持随机访问 (修复点: 补回丢失的定义)

type SequencedCollection

type SequencedCollection[E any] interface {
	Collection[E]
	AddFirst(e E)
	AddLast(e E)
	GetFirst() E
	GetLast() E
	RemoveFirst() E
	RemoveLast() E
	Reversed() []E
}

SequencedCollection 顺序集合接口 (Java 21+)

type Set

type Set[E any] interface {
	Collection[E]
}

Set 集合接口

type SortedMap

type SortedMap[K cmp.Ordered, V any] interface {
	Map[K, V]
	FirstKey() K
	LastKey() K
}

type SubList

type SubList[E any] struct {
	// contains filtered or unexported fields
}

func (*SubList[E]) Add

func (s *SubList[E]) Add(e E) bool

func (*SubList[E]) AddAll

func (s *SubList[E]) AddAll(c Collection[E]) bool

func (*SubList[E]) AddAllAtIndex

func (s *SubList[E]) AddAllAtIndex(index int, c Collection[E]) bool

func (*SubList[E]) AddAtIndex

func (s *SubList[E]) AddAtIndex(index int, element E)

func (*SubList[E]) AddFirst

func (s *SubList[E]) AddFirst(e E)

Sequenced

func (*SubList[E]) AddLast

func (s *SubList[E]) AddLast(e E)

func (*SubList[E]) All

func (s *SubList[E]) All() iter.Seq[E]

SubList Iterator

func (*SubList[E]) Clear

func (s *SubList[E]) Clear()

func (*SubList[E]) Clone

func (s *SubList[E]) Clone() *SubList[E]

func (*SubList[E]) Contains

func (s *SubList[E]) Contains(e E) bool

func (*SubList[E]) ContainsAll

func (s *SubList[E]) ContainsAll(c Collection[E]) bool

func (*SubList[E]) ForEach

func (s *SubList[E]) ForEach(action func(E))

func (*SubList[E]) Get

func (s *SubList[E]) Get(index int) E

func (*SubList[E]) GetFirst

func (s *SubList[E]) GetFirst() E

func (*SubList[E]) GetLast

func (s *SubList[E]) GetLast() E

func (*SubList[E]) IndexOf

func (s *SubList[E]) IndexOf(e E) int

func (*SubList[E]) IsEmpty

func (s *SubList[E]) IsEmpty() bool

func (*SubList[E]) LastIndexOf

func (s *SubList[E]) LastIndexOf(e E) int

func (*SubList[E]) ListIterator

func (s *SubList[E]) ListIterator() ListIterator[E]

func (*SubList[E]) Remove

func (s *SubList[E]) Remove(e E) bool

func (*SubList[E]) RemoveAll

func (s *SubList[E]) RemoveAll(c Collection[E]) bool

SubList RemoveAll O(N) 实现 (原为 panic)

func (*SubList[E]) RemoveAtIndex

func (s *SubList[E]) RemoveAtIndex(index int) E

func (*SubList[E]) RemoveFirst

func (s *SubList[E]) RemoveFirst() E

func (*SubList[E]) RemoveIf

func (s *SubList[E]) RemoveIf(filter func(E) bool) bool

SubList RemoveIf O(N) 实现 (原为 panic)

func (*SubList[E]) RemoveLast

func (s *SubList[E]) RemoveLast() E

func (*SubList[E]) RemoveRange

func (s *SubList[E]) RemoveRange(from, to int)

func (*SubList[E]) ReplaceAll

func (s *SubList[E]) ReplaceAll(op func(E) E)

func (*SubList[E]) RetainAll

func (s *SubList[E]) RetainAll(c Collection[E]) bool

SubList RetainAll O(N) 实现 (原为 panic)

func (*SubList[E]) Reversed

func (s *SubList[E]) Reversed() []E

func (*SubList[E]) Set

func (s *SubList[E]) Set(index int, element E) E

func (*SubList[E]) Size

func (s *SubList[E]) Size() int

func (*SubList[E]) Sort

func (s *SubList[E]) Sort(less func(a, b E) int)

func (*SubList[E]) SubList

func (s *SubList[E]) SubList(from, to int) List[E]

func (*SubList[E]) ToSlice

func (s *SubList[E]) ToSlice() []E

type SynchronousQueue

type SynchronousQueue[E any] struct {
	// contains filtered or unexported fields
}

SynchronousQueue 同步队列 v4 (Instruction-Counting Edition)

性能说明 v4:

  1. 指令级自旋 (Instruction-Counting Spin): 针对 <1µs 的极短超时, 摒弃 time.Now() 系统调用,改用 CPU 指令计数估算时间。 这彻底解决了 Windows/Linux 下高频获取时间带来的性能崩塌, 实现了真正的纳秒级 (10ns-100ns) 响应。

func NewSynchronousQueue

func NewSynchronousQueue[E any](fair bool) *SynchronousQueue[E]

func (*SynchronousQueue[E]) Add

func (q *SynchronousQueue[E]) Add(e E) bool

func (*SynchronousQueue[E]) AddAll

func (q *SynchronousQueue[E]) AddAll(c Collection[E]) bool

func (*SynchronousQueue[E]) All

func (q *SynchronousQueue[E]) All() iter.Seq[E]

func (*SynchronousQueue[E]) Clear

func (q *SynchronousQueue[E]) Clear()

func (*SynchronousQueue[E]) Contains

func (q *SynchronousQueue[E]) Contains(e E) bool

func (*SynchronousQueue[E]) ContainsAll

func (q *SynchronousQueue[E]) ContainsAll(c Collection[E]) bool

func (*SynchronousQueue[E]) DrainTo

func (q *SynchronousQueue[E]) DrainTo(c Collection[E]) int

DrainTo 移除此队列中所有可用的元素

func (*SynchronousQueue[E]) DrainToN

func (q *SynchronousQueue[E]) DrainToN(c Collection[E], maxElements int) int

DrainToN 最多移除给定数量的元素

func (*SynchronousQueue[E]) Element

func (q *SynchronousQueue[E]) Element() E

func (*SynchronousQueue[E]) IsEmpty

func (q *SynchronousQueue[E]) IsEmpty() bool

func (*SynchronousQueue[E]) Offer

func (q *SynchronousQueue[E]) Offer(e E) bool

func (*SynchronousQueue[E]) OfferTimeout

func (q *SynchronousQueue[E]) OfferTimeout(e E, timeout time.Duration) bool

OfferTimeout 插入元素,带超时 (v4 终极优化版)

func (*SynchronousQueue[E]) Peek

func (q *SynchronousQueue[E]) Peek() (E, bool)

func (*SynchronousQueue[E]) Poll

func (q *SynchronousQueue[E]) Poll() (E, bool)

func (*SynchronousQueue[E]) PollTimeout

func (q *SynchronousQueue[E]) PollTimeout(timeout time.Duration) (E, bool)

PollTimeout 获取元素,带超时 (v4 终极优化版)

func (*SynchronousQueue[E]) Put

func (q *SynchronousQueue[E]) Put(e E)

func (*SynchronousQueue[E]) RemainingCapacity

func (q *SynchronousQueue[E]) RemainingCapacity() int

RemainingCapacity 始终返回 0

func (*SynchronousQueue[E]) Remove

func (q *SynchronousQueue[E]) Remove(e E) bool

func (*SynchronousQueue[E]) RemoveAll

func (q *SynchronousQueue[E]) RemoveAll(c Collection[E]) bool

func (*SynchronousQueue[E]) RemoveHead

func (q *SynchronousQueue[E]) RemoveHead() E

func (*SynchronousQueue[E]) RetainAll

func (q *SynchronousQueue[E]) RetainAll(c Collection[E]) bool

func (*SynchronousQueue[E]) Size

func (q *SynchronousQueue[E]) Size() int

func (*SynchronousQueue[E]) String

func (q *SynchronousQueue[E]) String() string

func (*SynchronousQueue[E]) Take

func (q *SynchronousQueue[E]) Take() E

func (*SynchronousQueue[E]) ToSlice

func (q *SynchronousQueue[E]) ToSlice() []E

type TreeMap

type TreeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

TreeMap 基于红黑树的有序映射 优化等级: Physical Limit (Hybrid Allocator + Inline Search + Inline Rotation + Struct Layout)

func NewTreeMap

func NewTreeMap[K comparable, V any](comparator Comparator[K]) *TreeMap[K, V]

func (*TreeMap[K, V]) CeilingKey

func (m *TreeMap[K, V]) CeilingKey(key K) (K, bool)

func (*TreeMap[K, V]) Clear

func (m *TreeMap[K, V]) Clear()

func (*TreeMap[K, V]) Compute

func (m *TreeMap[K, V]) Compute(key K, remappingFunction func(K, V) V) V

func (*TreeMap[K, V]) ComputeIfAbsent

func (m *TreeMap[K, V]) ComputeIfAbsent(key K, mappingFunction func(K) V) V

func (*TreeMap[K, V]) ComputeIfPresent

func (m *TreeMap[K, V]) ComputeIfPresent(key K, remappingFunction func(K, V) V) V

func (*TreeMap[K, V]) ContainsKey

func (m *TreeMap[K, V]) ContainsKey(key K) bool

func (*TreeMap[K, V]) ContainsValue

func (m *TreeMap[K, V]) ContainsValue(value V) bool

func (*TreeMap[K, V]) EntrySet

func (m *TreeMap[K, V]) EntrySet() Set[Entry[K, V]]

func (*TreeMap[K, V]) FirstKey

func (m *TreeMap[K, V]) FirstKey() K

func (*TreeMap[K, V]) FloorKey

func (m *TreeMap[K, V]) FloorKey(key K) (K, bool)

func (*TreeMap[K, V]) ForEach

func (m *TreeMap[K, V]) ForEach(action func(K, V))

func (*TreeMap[K, V]) Get

func (m *TreeMap[K, V]) Get(key K) V

Get 极速读取

func (*TreeMap[K, V]) GetFound

func (m *TreeMap[K, V]) GetFound(key K) (V, bool)

func (*TreeMap[K, V]) GetOrDefault

func (m *TreeMap[K, V]) GetOrDefault(key K, defaultValue V) V

func (*TreeMap[K, V]) HigherKey

func (m *TreeMap[K, V]) HigherKey(key K) (K, bool)

func (*TreeMap[K, V]) IsEmpty

func (m *TreeMap[K, V]) IsEmpty() bool

func (*TreeMap[K, V]) Keys

func (m *TreeMap[K, V]) Keys() Set[K]

func (*TreeMap[K, V]) LastKey

func (m *TreeMap[K, V]) LastKey() K

func (*TreeMap[K, V]) LowerKey

func (m *TreeMap[K, V]) LowerKey(key K) (K, bool)

func (*TreeMap[K, V]) MarshalJSON

func (m *TreeMap[K, V]) MarshalJSON() ([]byte, error)

func (*TreeMap[K, V]) Merge

func (m *TreeMap[K, V]) Merge(key K, value V, remappingFunction func(oldV, newV V) V) V

func (*TreeMap[K, V]) Put

func (m *TreeMap[K, V]) Put(key K, value V)

Put 物理极限写入

func (*TreeMap[K, V]) PutAll

func (m *TreeMap[K, V]) PutAll(other Map[K, V])

func (*TreeMap[K, V]) PutIfAbsent

func (m *TreeMap[K, V]) PutIfAbsent(key K, value V) V

func (*TreeMap[K, V]) Remove

func (m *TreeMap[K, V]) Remove(key K) bool

Remove 删除

func (*TreeMap[K, V]) RemoveEntry

func (m *TreeMap[K, V]) RemoveEntry(key K, value V) bool

func (*TreeMap[K, V]) Replace

func (m *TreeMap[K, V]) Replace(key K, oldValue V, newValue V) bool

func (*TreeMap[K, V]) ReplaceAll

func (m *TreeMap[K, V]) ReplaceAll(function func(K, V) V)

func (*TreeMap[K, V]) Size

func (m *TreeMap[K, V]) Size() int

func (*TreeMap[K, V]) String

func (m *TreeMap[K, V]) String() string

func (*TreeMap[K, V]) UnmarshalJSON

func (m *TreeMap[K, V]) UnmarshalJSON(data []byte) error

func (*TreeMap[K, V]) Values

func (m *TreeMap[K, V]) Values() Collection[V]

type TreeSet

type TreeSet[E any] struct {
	// contains filtered or unexported fields
}

TreeSet 优化等级: Physical Limit (Hybrid Bump-Pointer Allocator + SIMD Clear + Specialized RBT)

func NewTreeSet

func NewTreeSet[E any](comparator Comparator[E]) *TreeSet[E]

func NewTreeSetOf

func NewTreeSetOf[E any](comparator Comparator[E], elements ...E) *TreeSet[E]

func (*TreeSet[E]) Add

func (t *TreeSet[E]) Add(e E) bool

Add 实现 Set 语义 优化: 寄存器级变量复用

func (*TreeSet[E]) AddAll

func (t *TreeSet[E]) AddAll(c Collection[E]) bool

func (*TreeSet[E]) AddFirst

func (t *TreeSet[E]) AddFirst(e E)

func (*TreeSet[E]) AddLast

func (t *TreeSet[E]) AddLast(e E)

func (*TreeSet[E]) All

func (t *TreeSet[E]) All() iter.Seq[E]

func (*TreeSet[E]) Ceiling

func (t *TreeSet[E]) Ceiling(e E) (E, bool)

func (*TreeSet[E]) Clear

func (t *TreeSet[E]) Clear()

Clear 物理极限清空: SIMD Memory Reset 利用 Go clear() 原语调用汇编 memclr,速度达到内存带宽极限

func (*TreeSet[E]) Contains

func (t *TreeSet[E]) Contains(e E) bool

func (*TreeSet[E]) ContainsAll

func (t *TreeSet[E]) ContainsAll(c Collection[E]) bool

func (*TreeSet[E]) First

func (t *TreeSet[E]) First() E

func (*TreeSet[E]) Floor

func (t *TreeSet[E]) Floor(e E) (E, bool)

func (*TreeSet[E]) GetFirst

func (t *TreeSet[E]) GetFirst() E

func (*TreeSet[E]) GetLast

func (t *TreeSet[E]) GetLast() E

func (*TreeSet[E]) Higher

func (t *TreeSet[E]) Higher(e E) (E, bool)

func (*TreeSet[E]) IsEmpty

func (t *TreeSet[E]) IsEmpty() bool

func (*TreeSet[E]) Last

func (t *TreeSet[E]) Last() E

func (*TreeSet[E]) Lower

func (t *TreeSet[E]) Lower(e E) (E, bool)

func (*TreeSet[E]) MarshalJSON

func (t *TreeSet[E]) MarshalJSON() ([]byte, error)

func (*TreeSet[E]) PollFirst

func (t *TreeSet[E]) PollFirst() E

func (*TreeSet[E]) PollLast

func (t *TreeSet[E]) PollLast() E

func (*TreeSet[E]) Remove

func (t *TreeSet[E]) Remove(e E) bool

func (*TreeSet[E]) RemoveAll

func (t *TreeSet[E]) RemoveAll(c Collection[E]) bool

func (*TreeSet[E]) RemoveFirst

func (t *TreeSet[E]) RemoveFirst() E

func (*TreeSet[E]) RemoveLast

func (t *TreeSet[E]) RemoveLast() E

func (*TreeSet[E]) RetainAll

func (t *TreeSet[E]) RetainAll(c Collection[E]) bool

func (*TreeSet[E]) Reversed

func (t *TreeSet[E]) Reversed() []E

func (*TreeSet[E]) Size

func (t *TreeSet[E]) Size() int

func (*TreeSet[E]) String

func (t *TreeSet[E]) String() string

func (*TreeSet[E]) ToSlice

func (t *TreeSet[E]) ToSlice() []E

func (*TreeSet[E]) UnmarshalJSON

func (t *TreeSet[E]) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL