큐 두개로 스택 (1) 썸네일형 리스트형 ES6 자료구조 큐(Queue) 구현하기, 우선순위 큐 만들고, 큐 두개로 스택 만들기 큐(Queue)구현하기 큐는 선입선출(FIFO) 자료구조다. 배열을 기반으로 큐를 구현했다.포인트는 배열이라서 shift()메서드와 push()메서드가 있어서 구현이 훨씬 편리하다는 것이다.1234567891011121314151617181920212223242526272829303132333435363738394041class Queue{ constructor(){ this.dataStore= []; } toString(){ let result = ""; for(val of this.dataStore){ result = result + val + "\n"; } return result; } enqueue(element){ this.dataStore.push(element); } dequeue(){ re.. 이전 1 다음