Class: Set

Phaser.Structs. Set

A Set is a collection of unique elements.


new Set( [elements])

Parameters:
Name Type Argument Description
elements Array.<*> <optional>

An optional array of elements to insert into this Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 19)

Members


entries :Array.<*>

The entries of this Set. Stored internally as an array.

Type:
  • Array.<*>
Since: 3.0.0
Default Value:
  • []
Source: src/structs/Set.js (Line 39)

size :integer

The size of this Set. This is the number of entries within it.
Changing the size will truncate the Set if the given value is smaller than the current size.
Increasing the size larger than the current size has no effect.

Type:
  • integer
Since: 3.0.0
Source: src/structs/Set.js (Line 412)

Methods


clear()

Clears this Set so that it no longer contains any values.

Since: 3.0.0
Source: src/structs/Set.js (Line 295)
Returns:

This Set object.

Type
Phaser.Structs.Set

contains(value)

Returns true if this Set contains the given value, otherwise returns false.

Parameters:
Name Type Description
value *

The value to check for in this Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 312)
Returns:

true if the given value was found in this Set, otherwise false.

Type
boolean

delete(value)

Removes the given value from this Set if this Set contains that value.

Parameters:
Name Type Description
value *

The value to remove from the Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 125)
Returns:

This Set object.

Type
Phaser.Structs.Set

difference(set)

Returns a new Set containing all the values in this Set which are not also in the given Set.

Parameters:
Name Type Description
set Phaser.Structs.Set

The Set to perform the difference with.

Since: 3.0.0
Source: src/structs/Set.js (Line 385)
Returns:

A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method.

Type
Phaser.Structs.Set

dump()

Dumps the contents of this Set to the console via console.group.

Since: 3.0.0
Source: src/structs/Set.js (Line 150)

each(callback, callbackScope)

Passes each value in this Set to the given callback.
Use this function when you know this Set will be modified during the iteration, otherwise use iterate.

Parameters:
Name Type Description
callback EachSetCallback

The callback to be invoked and passed each value this Set contains.

callbackScope *

The scope of the callback.

Since: 3.0.0
Source: src/structs/Set.js (Line 171)
Returns:

This Set object.

Type
Phaser.Structs.Set

get(property, value)

Get an element of this Set which has a property of the specified name, if that property is equal to the specified value.
If no elements of this Set satisfy the condition then this method will return null.

Parameters:
Name Type Description
property string

The property name to check on the elements of this Set.

value *

The value to check for.

Since: 3.0.0
Source: src/structs/Set.js (Line 83)
Returns:

The first element of this Set that meets the required condition, or null if this Set contains no elements that meet the condition.

Type
*

getArray()

Returns an array containing all the values in this Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 110)
Returns:

An array containing all the values in this Set.

Type
Array.<*>

intersect(set)

Returns a new Set that contains only the values which are in this Set and that are also in the given Set.

Parameters:
Name Type Description
set Phaser.Structs.Set

The Set to intersect this set with.

Since: 3.0.0
Source: src/structs/Set.js (Line 358)
Returns:

The result of the intersection, as a new Set.

Type
Phaser.Structs.Set

iterate(callback, callbackScope)

Passes each value in this Set to the given callback.
For when you absolutely know this Set won't be modified during the iteration.

Parameters:
Name Type Description
callback EachSetCallback

The callback to be invoked and passed each value this Set contains.

callbackScope *

The scope of the callback.

Since: 3.0.0
Source: src/structs/Set.js (Line 216)
Returns:

This Set object.

Type
Phaser.Structs.Set

iterateLocal(callbackKey [, args])

Goes through each entry in this Set and invokes the given function on them, passing in the arguments.

Parameters:
Name Type Argument Description
callbackKey string

The key of the function to be invoked on each Set entry.

args * <optional>
<repeatable>

Additional arguments that will be passed to the callback, after the child.

Since: 3.0.0
Source: src/structs/Set.js (Line 260)
Returns:

This Set object.

Type
Phaser.Structs.Set

set(value)

Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect.

Parameters:
Name Type Description
value *

The value to insert into this Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 60)
Returns:

This Set object.

Type
Phaser.Structs.Set

union(set)

Returns a new Set containing all values that are either in this Set or in the Set provided as an argument.

Parameters:
Name Type Description
set Phaser.Structs.Set

The Set to perform the union with.

Since: 3.0.0
Source: src/structs/Set.js (Line 329)
Returns:

A new Set containing all the values in this Set and the Set provided as an argument.

Type
Phaser.Structs.Set