Skip to content

EnumerationMap

Overview

An object that contains a value for each item in an enumeration.

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class EnumerationMap

T = enumeration value type U = mapped value type

import { EnumerationMap } from 'scenerystack/phet-core';

Constructor

new EnumerationMap( enumeration : TEnumeration<T>, factory : ( t: T ) => U )

Instance Methods

get( entry : T ) : U

Returns the value associated with the given enumeration entry.

set( entry : T, value : U )

Sets the value associated with the given enumeration entry.

map( mapFunction : ( u: U, t: T ) => U ) : EnumerationMap<T, U>

Returns a new EnumerationMap with mapped values.

@param mapFunction - function( {}, {TEnumeration.} ): {*} @returns With the mapped values

forEach( callback : ( u: U, t: T ) => void )

Calls the callback on each item of the enumeration map.

@param callback - function(value:, enumerationValue:)

values() : U[]

Returns the values stored in the map, as an array

Source Code

See the source for EnumerationMap.ts in the phet-core repository.