일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- html
- Notting hill
- python
- 알고리즘
- cow
- Project
- cout
- C++
- UE4
- 영알남
- Polymorphism
- dictation
- unreal engine4
- html5
- 코딩도장
- if
- CSS
- Unreal
- endl
- Java
- codecademy
- for
- Bull
- Euler
- bool
- 파이썬
- std
- 파이선
- 연결리스트
- font weight
- Today
- Total
연결 리스트 - 큐 본문
Queue.h 파일
#include<iostream>
using namespace std;
class Node {
Node* link;
int data;
public:
Node(int val = 0) :data(val), link(NULL) {}
Node* getLink() { return link; }
void setLink(Node* next) { link = next; }
void display() { cout << "<" << data << ">"; }
};
LinkedQueue.h 파일
#include "Queue.h"
using namespace std;
class LinkedQueue {
Node* front;
Node* rear;
public:
LinkedQueue() :front(NULL), rear(NULL) {}
~LinkedQueue() { while (!isEmpty())delete dequeue(); }
bool isEmpty() { return front == NULL; }
void enqueue(Node* p) {
if (isEmpty())front = rear = p;
else {
rear->setLink(p);
rear = p;
}
}
Node* dequeue() {
if (isEmpty()) return NULL;
Node* p = front;
front = front->getLink();
if (front == NULL)rear = NULL;
return p;
}
Node* peek() { return front; }
void display() {
cout << "[큐 내용] : ";
for (Node* p = front; p != NULL; p = p->getLink())
p->display();
cout << endl;
}
};
'Programming > 기타 언어들' 카테고리의 다른 글
단축키 (0) | 2017.05.24 |
---|---|
언리얼의 데이터 유형 (0) | 2017.05.18 |
연결 리스트 - 스택 (0) | 2017.04.23 |
C++ rand() 함수 (0) | 2017.04.23 |
c++ 소수점 아래 고정 하기 (0) | 2017.04.15 |