Skip to content

Commit 5fa06a2

Browse files
committed
Merge pull request phaserjs#1325 from pnstickne/wip-collections
ArrayList/LinkedList updates
2 parents 9fb46c6 + aa3c21a commit 5fa06a2

6 files changed

Lines changed: 288 additions & 251 deletions

File tree

src/core/ArrayList.js

Lines changed: 0 additions & 210 deletions
This file was deleted.

src/core/Group.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,32 +1199,36 @@ Phaser.Group.prototype.postUpdate = function () {
11991199

12001200

12011201
/**
1202-
* Allows you to obtain a Phaser.ArrayList of children that return true for the given predicate
1202+
* Allows you to obtain a Phaser.ArraySet of children that return true for the given predicate
12031203
* For example:
1204+
*
12041205
* var healthyList = Group.filter(function(child, index, children) {
12051206
* return child.health > 10 ? true : false;
12061207
* }, true);
12071208
* healthyList.callAll('attack');
1209+
*
12081210
* Note: Currently this will skip any children which are Groups themselves.
1211+
*
12091212
* @method Phaser.Group#filter
12101213
* @param {function} predicate - The function that each child will be evaluated against. Each child of the Group will be passed to it as its first parameter, the index as the second, and the entire child array as the third
12111214
* @param {boolean} [checkExists=false] - If set only children with exists=true will be passed to the callback, otherwise all children will be passed.
1212-
* @return {Phaser.ArrayList} Returns an array list containing all the children that the predicate returned true for
1215+
* @return {Phaser.ArraySet} Returns an array list containing all the children that the predicate returned true for
12131216
*/
12141217
Phaser.Group.prototype.filter = function(predicate, checkExists) {
1215-
var index = -1,
1216-
length = this.children.length,
1217-
result = new Phaser.ArrayList();
1218+
var index = -1;
1219+
var length = this.children.length;
1220+
var results = [];
12181221

12191222
while(++index < length) {
12201223
var child = this.children[index];
12211224
if(!checkExists || (checkExists && child.exists)) {
12221225
if(predicate(child, index, this.children)) {
1223-
result.add(child);
1226+
results.push(child);
12241227
}
12251228
}
12261229
}
1227-
return result;
1230+
1231+
return new Phaser.ArraySet(results);
12281232
};
12291233

12301234
/**

src/input/Input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ Phaser.Input = function (game) {
285285

286286
/**
287287
* A list of interactive objects. The InputHandler components add and remove themselves from this list.
288-
* @property {Phaser.ArrayList} interactiveItems
288+
* @property {Phaser.ArraySet} interactiveItems
289289
*/
290-
this.interactiveItems = new Phaser.ArrayList();
290+
this.interactiveItems = new Phaser.ArraySet();
291291

292292
/**
293293
* @property {Phaser.Point} _localPoint - Internal cache var.

0 commit comments

Comments
 (0)