Spaces:
Sleeping
Sleeping
| /** | |
| * 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; | |