-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHDeck.h
70 lines (58 loc) · 1.69 KB
/
HDeck.h
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
#ifndef HDECK_H
#define HDECK_H
#include <stddef.h>
#include "HCard.h"
/*
HSlot Structure is equivalent to "Node".
This doesn't copy the original card spirit.
Instead, they hold card's address.
Be careful with using these address.
*/
typedef struct _HSlot_
{
/*
Member Variable
*/
struct _HSlot_ *prev;
struct _HSlot_ *next;
HCard const *data;
} HSlot;
HSlot *new_HSlot(void);
void delete_HSlot(HSlot *me);
/*
HDeck Structure is equivalent to "Double LinkedList".
* You have to use them as 0-biased index.
* about insert : New Slot will have input index.
This means that older one will be shifted.
Construction by : Kwon Se Kyu
*/
typedef struct _HDeck_
{
/*
Member Variable
*/
HSlot *first;
size_t size;
} HDeck;
/*
Constructor & Destructor
*/
HDeck *new_HDeck(void);
void delete_HDeck(HDeck *me);
/*
Member Function Origin : Don't use them directly.
*/
HSlot *HDeck_get(HDeck *me, int pos); // get N-th HSlot's Pointer
void HDeck_push(HDeck *me, HCard const *target);
void HDeck_pop(HDeck *me);
void HDeck_insert(HDeck *me, HCard const *target, int pos); // 0 <= pos < size. If you want to put data, use push.
void HDeck_remove(HDeck *me, int pos);
void HDeck_swap(HDeck *me, int pos_1, int pos_2);
void HDeck_shake(HDeck *me); // This will shake holding cards.
void HDeck_sort(HDeck *me); // General Sort by month, type, fivetype
void HDeck_lsort(HDeck *me); // Special Sort by fivetype
void HDeck_clear(HDeck *me); // Reset Deck but not de-allocate.
void HDeck_drawFrom(HDeck *me, HDeck *you, int pos); // Move a card from one deck to this.
void HDeck_import(HDeck *me, HCard const *CARD_SET);
void HDeck_print(HDeck *me); // For Debug
#endif