mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
# Conflicts: # src/og/entity/Entity.js # src/og/math/Mat4.js # src/og/webgl/Handler.js # src/og/webgl/callbacks.js # tests/Globe.test.js
54 lines
1005 B
JavaScript
54 lines
1005 B
JavaScript
/**
|
|
* @module og/Stack
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
class Node {
|
|
constructor() {
|
|
this.next = null;
|
|
this.prev = null;
|
|
this.data = null;
|
|
}
|
|
}
|
|
|
|
class Stack {
|
|
/**
|
|
*
|
|
* @param {number} [size]
|
|
*/
|
|
constructor(size = 256) {
|
|
this._current = new Node();
|
|
this._head = this._current;
|
|
|
|
for (var i = 0; i < size; i++) {
|
|
var n = new Node();
|
|
n.prev = this._current;
|
|
this._current.next = n;
|
|
this._current = n;
|
|
}
|
|
this._current = this._head;
|
|
}
|
|
|
|
current() {
|
|
return this._current;
|
|
}
|
|
|
|
push(data) {
|
|
this._current = this._current.next;
|
|
this._current.data = data;
|
|
}
|
|
|
|
pop(data) {
|
|
this._current = this._current.prev;
|
|
return this._current.next.data;
|
|
}
|
|
|
|
popPrev(data) {
|
|
this._current = this._current.prev;
|
|
return this._current.data;
|
|
}
|
|
}
|
|
|
|
export { Stack };
|