Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 뉴럴네트워크
- Addressables
- 알고리즘
- graphics
- 게임 물리
- c#
- C
- game dev
- 유니티
- gamedev
- untiy
- unity #graphics
- 딥러닝
- 게임 수학
- 다익스트라
- C++
- Game Development
- mnist
- Serialize
- 게임 개발
- Unity
- Programming
- rendering
Archives
- Today
- Total
Typing diary
링크드리스트 연습(C++) 본문
2018.2.5
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include <iostream>
using namespace std;
class Node
{
public:
Node() :
pNext(NULL),
pPrev(NULL)
{}
~Node() {
cout << Data << " Node소멸 확인" << endl;
}
int Data;
Node* pNext;
Node* pPrev;
};
class NodeList
{
private:
Node* pBegin;
Node* pEnd;
int Size;
public:
NodeList()
{
pBegin = new Node;
pEnd = new Node;
pBegin->pNext = pEnd;
pEnd->pPrev = pBegin;
Size = 0;
}
~NodeList()
{
ListClear();
delete pBegin;
delete pEnd;
}
void PuchBack(int Data)
{
Node* pNode = new Node;
pNode->Data = Data;
Node* pPrev = pEnd->pPrev;
pNode->pNext = pEnd;
pEnd->pPrev = pNode;
pNode->pPrev = pPrev;
pPrev->pNext = pNode;
++Size;
}
void ListClear()
{
Node* pNode = pBegin->pNext;
while (pNode->pNext != NULL)
{
Node* pNext = pNode->pNext;
delete pNode;
pNode = pNext;
}
Size = 0;
}
int PopFront()
{
Node* pNode = pBegin->pNext;
int Backup = pNode->Data;
pBegin->pNext = pNode->pNext;
delete pNode;
--Size;
return Backup;
}
bool CheckEmpty()
{
return (Size == 0);
}
};
int main()
{
NodeList list;
for (int i = 0; i < 10; ++i)
{
list.PuchBack(i);
}
while (!list.CheckEmpty())
{
cout << list.PopFront() << endl;
}
return 0;
}
|
cs |
'자료구조' 카테고리의 다른 글
Stack을 이용한 미로찾기 (0) | 2022.08.21 |
---|