phaser/Phaser/system/LinkedList.ts

50 lines
933 B
TypeScript
Raw Normal View History

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