Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • HashHelpers

Index

Properties

Static Readonly hashCollisionThreshold

hashCollisionThreshold: number = 100

Static Readonly hashPrime

hashPrime: number = 101

Static Readonly maxPrimeArrayLength

maxPrimeArrayLength: 2146435069 = 2146435069

这是比Array.MaxArrayLength小的最大质数

Static Readonly primes

primes: number[] = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369]

用来作为哈希表大小的质数表。 一个典型的调整大小的算法会在这个数组中选取比之前容量大两倍的最小质数。 假设我们的Hashtable当前的容量为x,并且添加了足够多的元素,因此需要进行大小调整。 调整大小首先计算2x,然后在表中找到第一个大于2x的质数,即如果质数的顺序是p_1,p_2,...,p_i,...,则找到p_n,使p_n-1 < 2x < p_n。 双倍对于保持哈希特操作的渐近复杂度是很重要的,比如添加。 拥有一个质数可以保证双倍哈希不会导致无限循环。 IE,你的哈希函数将是h1(key)+i*h2(key),0 <= i < size.h2和size必须是相对质数。

Methods

Static expandPrime

  • expandPrime(oldSize: number): number

Static getHashCode

  • getHashCode(str: any): number

Static getPrime

  • getPrime(min: number): number

Static isPrime

  • isPrime(candidate: number): boolean

Generated using TypeDoc