OpenSheetMusicDisplay
    Preparing search index...

    Class CollectionUtil

    This class implements static methods to perform useful operations on lists, dictionaries, ...

    Until OSMD 3.0, this file also added last(), contains() and clear() to Array.prototype, for all arrays of the page and of every TypeScript project importing OSMD. A library shouldn't change its host's built-ins, so they are gone. Instead:

    • array.last(): CollectionUtil.getLastElement(array) or array[array.length - 1]
    • array.contains(element): array.includes(element)
    • array.clear(): array.length = 0, JavaScript's way to empty an array in place, and all clear() did. It removes every element, so that they can be garbage collected, and everyone holding the array sees it empty (array = [] would make a new array and leave the old one as it is).
    Index
    • Type Parameters

      • T

      Parameters

      • array: T[]
      • element: T
      • cmp: (elem1: T, elem2: T) => number
      • startIndex: number = 0
      • endIndex: number = ...

      Returns number

    • Iterates through a dictionary and calls iterationFunction. If iterationFunction returns true the key gets stored. all stored key will finally be removed from the dictionary.

      Type Parameters

      • S
      • T
      • V

      Parameters

      • thisPointer: S
      • dict: Dictionary<T, V>
      • iterationFunction: (thisPointer: S, key: T, value: V) => boolean

      Returns void