Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FasterDictionary<TKey, TValue>

创建这个字典的原因只有一个: 我需要一个能让我直接以数组的形式对值进行迭代的字典,而不需要生成一个数组或使用迭代器。 对于这个目标是比标准字典快N倍。 Faster dictionary在大部分操作上也比标准字典快,但差别可以忽略不计。 唯一较慢的操作是在添加时调整内存大小,因为与标准数组相比,这个实现需要使用两个单独的数组。

Type parameters

  • TKey

  • TValue

Hierarchy

  • FasterDictionary

Index

Constructors

constructor

Properties

_buckets

_buckets: number[]

_collisions

_collisions: number = 0

_freeValueCellIndex

_freeValueCellIndex: number = 0

_values

_values: TValue[]

_valuesInfo

_valuesInfo: FastNode[]

Accessors

count

  • get count(): number

valuesArray

  • get valuesArray(): TValue[]

Methods

add

  • add(key: TKey, value: TValue): void

addValue

  • addValue(key: TKey, value: TValue, indexSet: { value: number }): boolean

clear

  • clear(): void

containsKey

  • containsKey(key: TKey): boolean

fastClear

  • fastClear(): void

getDirectValue

  • getDirectValue(index: number): TValue

getIndex

  • getIndex(key: TKey): number

getValuesArray

  • getValuesArray(count: { value: number }): TValue[]

remove

  • remove(key: TKey): boolean

trim

  • trim(): void

tryFindIndex

  • tryFindIndex(key: TKey, findIndex: { value: number }): boolean

tryGetValue

  • tryGetValue(key: TKey): TValue

Static hash

  • hash(key: any): number

Static reduce

  • reduce(x: number, n: number): number

Static updateLinkedList

  • updateLinkedList(index: number, valuesInfo: FastNode[]): void

Generated using TypeDoc