Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SmartArray<T>

Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.

Type parameters

  • T

Hierarchy

Implements

Index

Constructors

constructor

  • Instantiates a Smart Array.

    Parameters

    • capacity: number

      defines the default capacity of the array.

    Returns SmartArray

Properties

dataSearch playground for data

data: Array<T>

The full set of data from the array.

lengthSearch playground for length

length: number

The active length of the array.

Methods

concatSearch playground for concat

  • concat(array: any): void
  • Concats the active data with a given array.

    Parameters

    • array: any

      defines the data to concatenate with.

    Returns void

containsSearch playground for contains

  • contains(value: T): boolean
  • Returns whether an element is part of the active data.

    Parameters

    • value: T

      defines the value to look for

    Returns boolean

    true if found in the active data otherwise false

disposeSearch playground for dispose

  • dispose(): void
  • Releases all the data from the array as well as the array.

    Returns void

forEachSearch playground for forEach

  • forEach(func: (content: T) => void): void
  • Iterates over the active data and apply the lambda to them.

    Parameters

    • func: (content: T) => void

      defines the action to apply on each value.

        • (content: T): void
        • Parameters

          • content: T

          Returns void

    Returns void

indexOfSearch playground for indexOf

  • indexOf(value: T): number
  • Returns the position of a value in the active data.

    Parameters

    • value: T

      defines the value to find the index for

    Returns number

    the index if found in the active data otherwise -1

pushSearch playground for push

  • push(value: T): void
  • Pushes a value at the end of the active data.

    Parameters

    • value: T

      defines the object to push in the array.

    Returns void

resetSearch playground for reset

  • reset(): void
  • Resets the active data to an empty array.

    Returns void

sortSearch playground for sort

  • sort(compareFn: (a: T, b: T) => number): void
  • Sorts the full sets of data.

    Parameters

    • compareFn: (a: T, b: T) => number

      defines the comparison function to apply.

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method