Constructors

  • The constructor initializes the properties of an object, including default frequency, maximum value, a freqMap data structure, the most significant bit, and the count of negative frequencies.

    Parameters

    • -: {
          frequency?: number;
          max: number;
      }

      frequency: The default frequency value. It is optional and has a default value of 0.

      • Optional frequency?: number
      • max: number

    Returns BinaryIndexedTree

Accessors

  • get freq(): number
  • The above function returns the value of the protected variable _freq.

    Returns number

    The frequency value stored in the protected variable _freq.

  • get freqMap(): Record<number, number>
  • The function returns the frequency map of numbers.

    Returns Record<number, number>

    The _freqMap property, which is a record with number keys and number values, is being returned.

  • get negativeCount(): number
  • The function returns the value of the _negativeCount property.

    Returns number

    The method is returning the value of the variable _negativeCount, which is of type number.

Methods

  • The function _binarySearch performs a binary search to find the largest number that satisfies a given condition.

    Parameters

    • sum: number

      The sum parameter is a number that represents the target sum value.

    • before: ((x, y) => boolean)

      The before parameter is a function that takes two numbers x and y as arguments and returns a boolean value. It is used to determine if x is less than or equal to y. The purpose of this function is to compare two numbers and determine their order.

        • (x, y): boolean
        • Parameters

          • x: number
          • y: number

          Returns boolean

    Returns number

    the value of the variable "left".

  • The function checks if the given index is valid and within the range.

    Parameters

    • index: number

      The parameter "index" is of type number and represents the index value that needs to be checked.

    Returns void

  • The function returns the value of a specific index in a freqMap data structure, or a default value if the index is not found.

    Parameters

    • index: number

      The index parameter is a number that represents the index of a node in a freqMap data structure.

    Returns number

    a number.

  • The _read function calculates the sum of values in a binary freqMap up to a given count.

    Parameters

    • count: number

      The count parameter is a number that represents the number of elements to read from the freqMap.

    Returns number

    the sum of the values obtained from calling the _getFrequency method for each index in the range from count to 1.

  • The function calculates the sum of elements in an array up to a given index using a binary indexed freqMap.

    Parameters

    • index: number

      The index parameter is a number that represents the index of an element in a data structure.

    Returns number

    a number.

  • The _update function updates the values in a binary indexed freqMap starting from a given index and propagating the changes to its parent nodes.

    Parameters

    • index: number

      The index parameter is a number that represents the index of the element in the data structure that needs to be updated.

    • delta: number

      The delta parameter represents the change in value that needs to be applied to the elements in the data structure.

    Returns void

  • The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.

    Parameters

    • index: number

      The index parameter is a number that represents the index of the freqMap element that needs to be updated.

    • delta: number

      The delta parameter represents the change in value that needs to be added to the freqMap at the specified index.

    Returns void

  • The function _updateNegativeCount updates a counter based on changes in frequency values.

    Parameters

    • freqCur: number

      The current frequency value.

    • freqNew: number

      The freqNew parameter represents the new frequency value.

    Returns void

  • The _writeSingle function updates the frequency at a specific index and triggers a callback if the frequency has changed.

    Parameters

    • index: number

      The index parameter is a number that represents the index of the element being modified or accessed.

    • freq: number

      The freq parameter represents the new frequency value that needs to be written to the specified index index.

    Returns void

  • The function calculates the prefix sum of an array using a binary indexed tree.

    Parameters

    • i: number

      The parameter "i" in the function "getPrefixSum" represents the index of the element in the array for which we want to calculate the prefix sum.

    Returns number

    The function getPrefixSum returns the prefix sum of the elements in the binary indexed tree up to index i.

  • The function returns the lower bound of a non-descending sequence that sums up to a given number.

    Parameters

    • sum: number

      The sum parameter is a number that represents the target sum that we want to find in the sequence.

    Returns number

    The lowerBound function is returning a number.

  • The read function takes a count parameter, checks if it is an integer, and returns the result of calling the _read function with the count parameter clamped between 0 and the maximum value.

    Parameters

    • count: number

      The count parameter is a number that represents the number of items to read.

    Returns number

    a number.

  • The function "readSingle" reads a single number from a specified index.

    Parameters

    • index: number

      The index parameter is a number that represents the index of an element in a collection or array.

    Returns number

    a number.

  • The "update" function updates the value at a given index by adding a delta and triggers a callback to notify of the change.

    Parameters

    • position: number

      The index parameter represents the index of the element that needs to be updated in the data structure.

    • change: number

      The "delta" parameter represents the change in value that needs to be applied to the frequency at the specified index.

    Returns void

  • The upperBound function returns the index of the first element in a sequence that is greater than or equal to a given sum.

    Parameters

    • sum: number

      The "sum" parameter is a number that represents the target sum that we want to find in the sequence.

    Returns number

    The upperBound function is returning a number.

  • The function "writeSingle" checks the index and writes a single value with a given frequency.

    Parameters

    • index: number

      The index parameter is a number that represents the index of an element. It is used to identify the specific element that needs to be written.

    • freq: number

      The freq parameter represents the frequency value that needs to be written.

    Returns void

Generated using TypeDoc