Spaces:
Sleeping
Sleeping
File size: 999 Bytes
e4bf523 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 'use strict'
/**
* Copyright (c) 2017~2019, OBCon Inc.
* All rights reserved.
*/
/**
* @file
* @copyright 2017~2019, OBCon Inc.
* @author gye hyun james kim [pnuskgh@gmail.com]
*/
class Stack { //--- LIFO (Last In First Out)
constructor(data) {
this.data = data || [];
}
getBuffer() { //--- Stack 복사
return this.data.slice();
}
isEmpty() {
return this.data.length == 0;
}
peek() { //--- 최상위 항목을 조회
return (this.isEmpty()) ? null : this.data[this.data.length - 1];
}
push(item) { //--- 항목 추가
this.data.push(item);
}
pop() { //--- 항목 제거
return this.data.pop();
}
}
module.exports = Stack;
|