<commit_before>const stringHash = require('../StringHash')
const createLinkedList = require('./SinglyLinkedList')
/**
 * Hash table is basic data structure used to implement associative array,
 * mapping keys to values. It uses a hash function to compute an index of array
 * where value can be found.
 *
 * Application:
 * Hash table is widely used data structure due to its performance.
 * Hash tables are used to implement associative arrays, sets, caches,
 * database indexes etc.
 *
 * Usage:
 * const createHashTable = require('./HashTable')
 * const hashTable = createHashTable()
 * hashTable.set('A', 'B')
 * hashTable.get('A') // => 'B'
 * hashTable.remove('A') // => true
 * hashTable.get('A') // => null
 *
 * @param input
 * @param {Function} hashFunc
 */
module.exports = (hashFunc = stringHash) => {
  let length = 0
  let table = []

  return {
    size,
    set,
    get,
    remove
  }

  /**
   * Get hash table size.
   *
   * Performance: O(1)
   * @returns {Number}
   */
  function size () {
    return length
  }

  /**
   * Save `value` in hash table with `key`.
   *
   * Performance: O(1)
   * @param {String|Number} key
   * @param {*} value<commit_msg>Change table to constant.<commit_after>const stringHash = require('../StringHash')
const createLinkedList = require('./SinglyLinkedList')
/**
 * Hash table is basic data structure used to implement associative array,
 * mapping keys to values. It uses a hash function to compute an index of array
 * where value can be found.
 *
 * Application:
 * Hash table is widely used data structure due to its performance.
 * Hash tables are used to implement associative arrays, sets, caches,
 * database indexes etc.
 *
 * Usage:
 * const createHashTable = require('./HashTable')
 * const hashTable = createHashTable()
 * hashTable.set('A', 'B')
 * hashTable.get('A') // => 'B'
 * hashTable.remove('A') // => true
 * hashTable.get('A') // => null
 *
 * @param input
 * @param {Function} hashFunc
 */
module.exports = (hashFunc = stringHash) => {
  const table = []
  let length = 0

  return {
    size,
    set,
    get,
    remove
  }

  /**
   * Get hash table size.
   *
   * Performance: O(1)
   * @returns {Number}
   */
  function size () {
    return length
  }

  /**
   * Save `value` in hash table with `key`.
   *
   * Performance: O(1)
   * @param {String|Number} key
   * @param {*} value
{'fraction_non_alphanumeric': 0.13858466722830665, 'fraction_numerical': 0.002527379949452401, 'mean_word_length': 3.0050590219224285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7126776', 'n_tokens_mistral': 728, 'n_tokens_neox': 711, 'n_words': 244}