phaser/Phaser/math/LinkedList.ts

50 lines
964 B
TypeScript
Raw Normal View History

2013-05-29 01:58:56 +00:00
/// <reference path="../gameobjects/IGameObject.ts" />
2013-04-12 16:19:56 +00:00
/**
2013-04-18 15:49:08 +00:00
* Phaser - LinkedList
*
* A miniature linked list class. Useful for optimizing time-critical or highly repetitive tasks!
2013-04-18 13:16:18 +00:00
*/
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
module Phaser {
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
export class LinkedList {
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
/**
* Creates a new link, and sets <code>object</code> and <code>next</code> to <code>null</code>.
*/
constructor() {
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
this.object = null;
this.next = null;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
}
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
/**
2013-05-29 01:58:56 +00:00
* Stores a reference to an <code>IGameObject</code>.
2013-04-18 13:16:18 +00:00
*/
2013-05-29 01:58:56 +00:00
public object: IGameObject;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
/**
* Stores a reference to the next link in the list.
*/
public next: LinkedList;
/**
* Clean up memory.
*/
public destroy() {
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
this.object = null;
2013-04-12 16:19:56 +00:00
2013-04-18 13:16:18 +00:00
if (this.next != null)
{
this.next.destroy();
}
this.next = null;
}
2013-04-12 16:19:56 +00:00
}
2013-04-18 13:16:18 +00:00
}