|
ysf.wlanwq.ZJSWL 1922~1991 (韦舒豪)
|
1ms |
6.2 MiB |
C++17 |
103 Bytes |
2024-7-29 16:34:00 |
|
何中蓉
|
1ms |
7.2 MiB |
C++11 |
97 Bytes |
2024-4-22 20:49:21 |
|
郑qr
|
1ms |
6.9 MiB |
C++11 |
86 Bytes |
2024-6-2 13:56:57 |
|
黄宇博 (huangyvbo)
|
1ms |
6.8 MiB |
C++11 |
108 Bytes |
2024-6-15 13:09:09 |
|
肖艺勋
|
1ms |
6.8 MiB |
|
103 Bytes |
2023-10-20 19:29:59 |
|
星野 光 (Hoshino Hikari)
|
1ms |
6.8 MiB |
|
85 Bytes |
2023-10-22 22:24:07 |
|
1 (高梓睿23025)
|
1ms |
6.5 MiB |
|
93 Bytes |
2023-9-3 14:00:46 |
|
>﹏< AAA?白猫YYDS (爱搞笑的张浩宇)
|
1ms |
6.5 MiB |
|
93 Bytes |
2023-9-3 17:33:52 |
|
陈致远Lynn
|
1ms |
8 MiB |
|
88 Bytes |
2023-5-13 19:17:41 |
|
qhx
|
1ms |
6.8 MiB |
C++98(O2) |
101 Bytes |
2024-8-4 20:52:48 |
|
Guest
|
1ms |
6.9 MiB |
C++98(O2) |
96 Bytes |
2024-8-24 10:43:31 |
|
神秘白客6
|
1ms |
6.8 MiB |
C++98(O2) |
102 Bytes |
2024-8-19 12:10:41 |
|
余sy
|
1ms |
6.9 MiB |
C++11 |
87 Bytes |
2024-6-2 13:57:13 |
|
qinlang
|
1ms |
8 MiB |
|
88 Bytes |
2023-5-13 19:18:11 |
|
qinlang
|
1ms |
8.1 MiB |
|
88 Bytes |
2023-5-13 19:18:20 |
|
赵耘毅
|
1ms |
8.1 MiB |
|
89 Bytes |
2023-5-13 20:07:48 |
|
kongql
|
1ms |
6.8 MiB |
C++11 |
84 Bytes |
2024-5-11 15:23:33 |
|
原著校区 巫映秋 (巫映秋1a)
|
1ms |
6.8 MiB |
|
86 Bytes |
2023-10-26 20:53:24 |
|
葛琮扬
|
1ms |
8 MiB |
|
57 Bytes |
2023-2-16 19:52:28 |
|
莎莎罗
|
1ms |
6.7 MiB |
C++98(O2) |
93 Bytes |
2024-6-21 18:00:31 |
|
史继来
|
1ms |
6.7 MiB |
|
91 Bytes |
2023-9-27 18:16:28 |
|
qinlang
|
1ms |
8.1 MiB |
|
88 Bytes |
2023-5-13 19:18:12 |
|
新壹街-李昕宇 (李昕宇)
|
1ms |
6.4 MiB |
C++98 |
155 Bytes |
2024-7-5 8:51:20 |
|
郭睿
|
1ms |
6.7 MiB |
C++98 |
103 Bytes |
2024-5-25 13:06:02 |
|
郑qr
|
1ms |
6.9 MiB |
C++11 |
86 Bytes |
2024-6-2 13:57:15 |
|
RALY染妗(TINHOIYUI)
|
1ms |
6.7 MiB |
|
84 Bytes |
2023-10-14 14:28:12 |
|
喻琦皓
|
1ms |
6.7 MiB |
|
76 Bytes |
2023-9-30 10:09:33 |
|
缪京辰
|
1ms |
6.8 MiB |
C++98(O2) |
96 Bytes |
2024-7-1 18:55:18 |
|
余sy
|
1ms |
6.9 MiB |
C++11 |
87 Bytes |
2024-6-2 13:57:05 |
|
金沙校区-王俊元 (王俊元)
|
1ms |
6.5 MiB |
|
92 Bytes |
2023-9-2 10:30:44 |
|
胡婉琳
|
1ms |
7 MiB |
C++98(O2) |
96 Bytes |
2024-5-5 10:07:13 |
|
余sy
|
1ms |
6.9 MiB |
C++11 |
87 Bytes |
2024-6-2 13:57:58 |
|
wanghuaiying
|
1ms |
6.7 MiB |
|
110 Bytes |
2023-9-30 16:44:10 |
|
金沙校区-冉一梵 (冉一梵)
|
1ms |
6.6 MiB |
|
105 Bytes |
2023-9-22 17:02:52 |
|
拥抱幸福小熊(吴沛篪)
|
1ms |
6.8 MiB |
|
92 Bytes |
2023-10-14 14:27:31 |
|
郑汪洋23025
|
1ms |
6.5 MiB |
|
93 Bytes |
2023-9-3 14:02:21 |
|
陈家熠
|
1ms |
6.7 MiB |
|
164 Bytes |
2023-9-3 16:58:50 |
|
郑qr
|
1ms |
6.8 MiB |
C++11 |
86 Bytes |
2024-6-2 13:59:29 |
|
余sy
|
1ms |
6.9 MiB |
C++11 |
87 Bytes |
2024-6-2 13:58:07 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:02 |
|
qinlang
|
1ms |
8.1 MiB |
|
88 Bytes |
2023-5-13 19:18:29 |
|
韩俊毅
|
1ms |
8.1 MiB |
|
91 Bytes |
2023-5-13 19:19:30 |
|
huangxiangming
|
1ms |
6.7 MiB |
|
92 Bytes |
2022-4-8 12:09:12 |
|
Aphrode
|
1ms |
6.8 MiB |
|
152 Bytes |
2023-10-20 19:26:28 |
|
tangchenqian
|
1ms |
7.2 MiB |
|
75 Bytes |
2022-9-17 14:33:35 |
|
孙晨淏 (sunchenhao)
|
1ms |
7.3 MiB |
|
94 Bytes |
2022-9-17 14:28:03 |
|
Him神
|
1ms |
6.6 MiB |
|
97 Bytes |
2023-9-25 21:00:20 |
|
zhaoyinjie23005
|
1ms |
6.5 MiB |
|
86 Bytes |
2023-9-2 19:23:31 |
|
星野 光 (Hoshino Hikari)
|
1ms |
6.8 MiB |
|
85 Bytes |
2023-10-22 22:23:49 |
|
pengjinhua23005
|
1ms |
6.5 MiB |
|
88 Bytes |
2023-8-26 14:27:11 |
|
yuzk
|
1ms |
6.1 MiB |
C++11 |
96 Bytes |
2024-7-10 18:05:55 |
|
金沙校区 - 刘昱辰 (liuyuchen002)
|
1ms |
7.1 MiB |
C++98 |
97 Bytes |
2024-5-12 10:11:54 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:03 |
|
666
|
1ms |
7.2 MiB |
|
70 Bytes |
2022-9-17 14:35:46 |
|
褚博艺
|
1ms |
6.7 MiB |
|
72 Bytes |
2023-9-20 22:15:18 |
|
赵耘毅
|
1ms |
8.1 MiB |
|
89 Bytes |
2023-5-13 20:07:45 |
|
RanHao
|
1ms |
6.5 MiB |
|
140 Bytes |
2023-8-26 14:27:49 |
|
郑qr
|
1ms |
6.9 MiB |
C++11 |
86 Bytes |
2024-6-2 13:56:48 |
|
Guest
|
1ms |
6.9 MiB |
C++98(O2) |
83 Bytes |
2024-5-25 12:20:13 |
|
手搓STL stack 双向无环链表 _ 向量 2种实现方式: template <typename Map_Type> class Stack_l /* Stack _ List */ { private: struct Node { Map_Type Node_Data; Node *nextp, *lastp; Node(void) { nextp = 0; lastp = 0; } }; struct List_Data { unsigned int List_Size; Node *headp, *endp; List_Data(void) { List_Size = 0; headp = 0; endp = 0; } }Data; struct Vector_Data { Map_Type *headp, *lastp, *endp; void resize(unsigned int data_size) { Map_Type *newp = new Map_Type[data_size](); endp = newp + data_size - 1; lastp = newp + (data_size > lastp - headp ? lastp - headp : data_size); if (headp) delete[] headp; headp = newp; } Vector_Data(void) { headp = 0; lastp = 0; endp = 0; } }; public: unsigned int size(void) { return Data.List_Size; } Map_Type& top(void) { return Data.endp -> Node_Data; } void* data(void) { return &Data; } bool empty(void) { return !((bool)Data.headp); } Stack_l<Map_Type>& push(Map_Type push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(Map_Type& push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(Map_Type* push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = *push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(const Map_Type* push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = *(Map_Type*)push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& pop(void) { if (Data.headp) { if (Data.List_Size == 1u) { delete Data.headp; Data.List_Size = 0; Data.headp = 0; Data.endp = 0; } else { Data.endp = Data.endp -> lastp; delete Data.endp -> nextp; Data.endp -> nextp = 0; --Data.List_Size; } } return *this; } Stack_l<Map_Type>& clear(void) { while (Data.List_Size) { pop(); } return *this; } Stack_l<Map_Type>(void) { /* NULL */ } Stack_l<Map_Type>(unsigned int data_size, Map_Type map_data) { Data.List_Size = data_size; while (data_size--) { Node *nodep = new Node(); nodep -> Node_Data = map_data; if (Data.headp) { nodep -> lastp = Data.endp; Data.endp -> nextp = nodep; Data.endp = nodep; } else { Data.headp = nodep; Data.endp = nodep; } } } Stack_l<Map_Type>(Stack_l<Map_Type>& map_data) { if (!map_data.empty()) { List_Data *listp = (List_Data*)map_data.data(); Node *nodep = listp -> headp, *newp; for (unsigned int i = 0; i != listp -> List_Size; ++i, nodep = nodep -> nextp) { newp = new Node(); newp -> Node_Data = nodep -> Node_Data; if (Data.headp) { newp -> lastp = Data.endp; Data.endp -> nextp = newp; Data.endp = newp; } else { Data.headp = newp; Data.endp = newp; } } Data.List_Size = listp -> List_Size; } } Stack_l<Map_Type>& operator=(Stack_l<Map_Type>& copy_data) { if (copy_data.empty()) return *this; List_Data *listp = (List_Data*)copy_data.data(); Node *nodep = listp -> headp, *newp; for (unsigned int i = 0; i != listp -> List_Size; ++i, nodep = nodep -> nextp) { newp = new Node(); newp -> Node_Data = nodep -> Node_Data; if (Data.headp) { newp -> lastp = Data.endp; Data.endp -> nextp = newp; Data.endp = newp; } else { Data.headp = newp; Data.endp = newp; } } Data.List_Size = listp -> List_Size; return *this; } bool operator==(Stack_l<Map_Type>& cmp_data) { if (cmp_data.size() != Data.List_Size) return false; else if (cmp_data.empty() && (!Data.List_Size)) return true; Node *nodep1 = Data.headp, *nodep2 = ((List_Data*)cmp_data.data()) ->headp; for (unsigned int i = 0; i != Data.List_Size; ++i, nodep1 = nodep1 -> nextp, nodep2 = nodep2 ->nextp) { if (nodep1 -> Node_Data != nodep2 -> Node_Data) return false; } return true; } bool operator!=(Stack_l<Map_Type>& cmp_data) { if (cmp_data.size() == Data.List_Size) return false; else if (cmp_data.empty() && (!Data.List_Size)) return false; Node *nodep1 = Data.headp, *nodep2 = ((List_Data*)cmp_data.data()) ->headp; for (unsigned int i = 0; i != Data.List_Size; ++i, nodep1 = nodep1 -> nextp, nodep2 = nodep2 ->nextp) { if (nodep1 -> Node_Data != nodep2 -> Node_Data) return true; } return true; } ~Stack_l<Map_Type>(void) { clear(); } }; /* Stack _ List */ template <typename Map_Type> class Stack_v /* Stack _ Vector */ { private: struct Node { Map_Type Node_Data; Node *nextp, *lastp; Node(void) { nextp = 0; lastp = 0; } }; struct List_Data { unsigned int List_Size; Node *headp, *endp; List_Data(void) { List_Size = 0; headp = 0; endp = 0; } }; struct Vector_Data { Map_Type *headp, *lastp, *endp; void resize(unsigned int data_size) { Map_Type *newp = new Map_Type[data_size](); endp = newp + data_size - 1; lastp = newp + (data_size > lastp - headp ? lastp - headp : data_size); if (headp) delete[] headp; headp = newp; } Vector_Data(void) { headp = 0; lastp = 0; endp = 0; } }Data; public: unsigned int size(void) { return Data.lastp - Data.headp; } Map_Type& top(void) { return *(Data.lastp - 1); } void* data(void) { return &Data; } bool full(void) { if (!Data.headp) return true; return Data.endp + 1 == Data.lastp; } bool empty(void) { if (!Data.headp) return true; return Data.headp == Data.lastp; } Stack_v<Map_Type>& push(Map_Type push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(Map_Type& push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(Map_Type* push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = *push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(const Map_Type* push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = *(Map_Type*)push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& pop(void) { if (empty()) { if (Data.lastp - Data.headp > 1) Data.resize((Data.lastp - Data.headp) >> 1); else return *this; } else --Data.lastp; return *this; } Stack_v<Map_Type>(void) { /* NULL */ } Stack_v<Map_Type>(unsigned int data_size, Map_Type map_data) { while (data_size) { push(&map_data); --data_size; } } Stack_v<Map_Type>(Stack_v<Map_Type>& map_data) { Vector_Data *datap = (Vector_Data*)map_data.data(); for (unsigned int i = 0, k = map_data.size(); i != k; ++i) push(datap -> headp + i); } Stack_v<Map_Type>& operator=(Stack_v<Map_Type>& copy_data) { if (copy_data.empty()) clear(); else { Vector_Data *datap = (Vector_Data*)copy_data.data(); for (unsigned int i = 0, k = copy_data.size(); i != k; ++i) push(datap -> headp + i); } return *this; } bool operator==(Stack_v<Map_Type>& cmp_data) { if (size() != cmp_data.size()) return false; else if (empty() && cmp_data.empty()) return true; Vector_Data *datap = (Vector_Data*)cmp_data.data(); for (unsigned int i = 0, k = size(); i != k; ++i) { if (*(Data.headp + i) != *(datap ->headp + i)) return false; } return true; } bool operator!=(Stack_v<Map_Type>& cmp_data) { if (size() != cmp_data.size()) return true; else if (empty() && cmp_data.empty()) return false; Vector_Data *datap = (Vector_Data*)cmp_data.data(); for (unsigned int i = 0, k = size(); i != k; ++i) { if (*(Data.headp + i) != *(datap -> headp + i)) return true; } return false; } Stack_v<Map_Type>& clear(void) { delete[] Data.headp; Data.headp = 0; Data.lastp = 0; Data.endp = 0; return *this; } ~Stack_v<Map_Type>(void) { delete[] Data.headp; } }; /* Stack _ Vector */ int main(void) { return 0; } (22029-xys)
|
1ms |
6.7 MiB |
|
87 Bytes |
2023-9-17 7:58:40 |
|
吴阮董
|
1ms |
7.1 MiB |
C++98(O2) |
110 Bytes |
2024-5-25 20:18:35 |
|
ysf.wlanwq.ZJSWL 1922~1991 (韦舒豪)
|
1ms |
7.2 MiB |
C++98 |
625 Bytes |
2024-4-20 15:41:32 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:04 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:01 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:02 |
|
郑qr
|
1ms |
6.9 MiB |
C++11 |
86 Bytes |
2024-6-2 13:58:13 |
|
Guest
|
1ms |
6.6 MiB |
C++98(O2) |
101 Bytes |
2024-7-17 20:53:39 |
|
手搓STL stack 双向无环链表 _ 向量 2种实现方式: template <typename Map_Type> class Stack_l /* Stack _ List */ { private: struct Node { Map_Type Node_Data; Node *nextp, *lastp; Node(void) { nextp = 0; lastp = 0; } }; struct List_Data { unsigned int List_Size; Node *headp, *endp; List_Data(void) { List_Size = 0; headp = 0; endp = 0; } }Data; struct Vector_Data { Map_Type *headp, *lastp, *endp; void resize(unsigned int data_size) { Map_Type *newp = new Map_Type[data_size](); endp = newp + data_size - 1; lastp = newp + (data_size > lastp - headp ? lastp - headp : data_size); if (headp) delete[] headp; headp = newp; } Vector_Data(void) { headp = 0; lastp = 0; endp = 0; } }; public: unsigned int size(void) { return Data.List_Size; } Map_Type& top(void) { return Data.endp -> Node_Data; } void* data(void) { return &Data; } bool empty(void) { return !((bool)Data.headp); } Stack_l<Map_Type>& push(Map_Type push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(Map_Type& push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(Map_Type* push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = *push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& push(const Map_Type* push_data) { Node *nodep = new Node(); nodep -> lastp = Data.endp; if (!Data.headp) { Data.headp = nodep; Data.endp = nodep; } else Data.endp -> nextp = nodep; Data.endp = nodep; nodep -> Node_Data = *(Map_Type*)push_data; ++Data.List_Size; return *this; } Stack_l<Map_Type>& pop(void) { if (Data.headp) { if (Data.List_Size == 1u) { delete Data.headp; Data.List_Size = 0; Data.headp = 0; Data.endp = 0; } else { Data.endp = Data.endp -> lastp; delete Data.endp -> nextp; Data.endp -> nextp = 0; --Data.List_Size; } } return *this; } Stack_l<Map_Type>& clear(void) { while (Data.List_Size) { pop(); } return *this; } Stack_l<Map_Type>(void) { /* NULL */ } Stack_l<Map_Type>(unsigned int data_size, Map_Type map_data) { Data.List_Size = data_size; while (data_size--) { Node *nodep = new Node(); nodep -> Node_Data = map_data; if (Data.headp) { nodep -> lastp = Data.endp; Data.endp -> nextp = nodep; Data.endp = nodep; } else { Data.headp = nodep; Data.endp = nodep; } } } Stack_l<Map_Type>(Stack_l<Map_Type>& map_data) { if (!map_data.empty()) { List_Data *listp = (List_Data*)map_data.data(); Node *nodep = listp -> headp, *newp; for (unsigned int i = 0; i != listp -> List_Size; ++i, nodep = nodep -> nextp) { newp = new Node(); newp -> Node_Data = nodep -> Node_Data; if (Data.headp) { newp -> lastp = Data.endp; Data.endp -> nextp = newp; Data.endp = newp; } else { Data.headp = newp; Data.endp = newp; } } Data.List_Size = listp -> List_Size; } } Stack_l<Map_Type>& operator=(Stack_l<Map_Type>& copy_data) { if (copy_data.empty()) return *this; List_Data *listp = (List_Data*)copy_data.data(); Node *nodep = listp -> headp, *newp; for (unsigned int i = 0; i != listp -> List_Size; ++i, nodep = nodep -> nextp) { newp = new Node(); newp -> Node_Data = nodep -> Node_Data; if (Data.headp) { newp -> lastp = Data.endp; Data.endp -> nextp = newp; Data.endp = newp; } else { Data.headp = newp; Data.endp = newp; } } Data.List_Size = listp -> List_Size; return *this; } bool operator==(Stack_l<Map_Type>& cmp_data) { if (cmp_data.size() != Data.List_Size) return false; else if (cmp_data.empty() && (!Data.List_Size)) return true; Node *nodep1 = Data.headp, *nodep2 = ((List_Data*)cmp_data.data()) ->headp; for (unsigned int i = 0; i != Data.List_Size; ++i, nodep1 = nodep1 -> nextp, nodep2 = nodep2 ->nextp) { if (nodep1 -> Node_Data != nodep2 -> Node_Data) return false; } return true; } bool operator!=(Stack_l<Map_Type>& cmp_data) { if (cmp_data.size() == Data.List_Size) return false; else if (cmp_data.empty() && (!Data.List_Size)) return false; Node *nodep1 = Data.headp, *nodep2 = ((List_Data*)cmp_data.data()) ->headp; for (unsigned int i = 0; i != Data.List_Size; ++i, nodep1 = nodep1 -> nextp, nodep2 = nodep2 ->nextp) { if (nodep1 -> Node_Data != nodep2 -> Node_Data) return true; } return true; } ~Stack_l<Map_Type>(void) { clear(); } }; /* Stack _ List */ template <typename Map_Type> class Stack_v /* Stack _ Vector */ { private: struct Node { Map_Type Node_Data; Node *nextp, *lastp; Node(void) { nextp = 0; lastp = 0; } }; struct List_Data { unsigned int List_Size; Node *headp, *endp; List_Data(void) { List_Size = 0; headp = 0; endp = 0; } }; struct Vector_Data { Map_Type *headp, *lastp, *endp; void resize(unsigned int data_size) { Map_Type *newp = new Map_Type[data_size](); endp = newp + data_size - 1; lastp = newp + (data_size > lastp - headp ? lastp - headp : data_size); if (headp) delete[] headp; headp = newp; } Vector_Data(void) { headp = 0; lastp = 0; endp = 0; } }Data; public: unsigned int size(void) { return Data.lastp - Data.headp; } Map_Type& top(void) { return *(Data.lastp - 1); } void* data(void) { return &Data; } bool full(void) { if (!Data.headp) return true; return Data.endp + 1 == Data.lastp; } bool empty(void) { if (!Data.headp) return true; return Data.headp == Data.lastp; } Stack_v<Map_Type>& push(Map_Type push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(Map_Type& push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(Map_Type* push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = *push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& push(const Map_Type* push_data) { if (full()) Data.resize((unsigned int)((Data.lastp - Data.headp) * 1.5) + 1); *Data.lastp = *(Map_Type*)push_data; ++Data.lastp; return *this; } Stack_v<Map_Type>& pop(void) { if (empty()) { if (Data.lastp - Data.headp > 1) Data.resize((Data.lastp - Data.headp) >> 1); else return *this; } else --Data.lastp; return *this; } Stack_v<Map_Type>(void) { /* NULL */ } Stack_v<Map_Type>(unsigned int data_size, Map_Type map_data) { while (data_size) { push(&map_data); --data_size; } } Stack_v<Map_Type>(Stack_v<Map_Type>& map_data) { Vector_Data *datap = (Vector_Data*)map_data.data(); for (unsigned int i = 0, k = map_data.size(); i != k; ++i) push(datap -> headp + i); } Stack_v<Map_Type>& operator=(Stack_v<Map_Type>& copy_data) { if (copy_data.empty()) clear(); else { Vector_Data *datap = (Vector_Data*)copy_data.data(); for (unsigned int i = 0, k = copy_data.size(); i != k; ++i) push(datap -> headp + i); } return *this; } bool operator==(Stack_v<Map_Type>& cmp_data) { if (size() != cmp_data.size()) return false; else if (empty() && cmp_data.empty()) return true; Vector_Data *datap = (Vector_Data*)cmp_data.data(); for (unsigned int i = 0, k = size(); i != k; ++i) { if (*(Data.headp + i) != *(datap ->headp + i)) return false; } return true; } bool operator!=(Stack_v<Map_Type>& cmp_data) { if (size() != cmp_data.size()) return true; else if (empty() && cmp_data.empty()) return false; Vector_Data *datap = (Vector_Data*)cmp_data.data(); for (unsigned int i = 0, k = size(); i != k; ++i) { if (*(Data.headp + i) != *(datap -> headp + i)) return true; } return false; } Stack_v<Map_Type>& clear(void) { delete[] Data.headp; Data.headp = 0; Data.lastp = 0; Data.endp = 0; return *this; } ~Stack_v<Map_Type>(void) { delete[] Data.headp; } }; /* Stack _ Vector */ int main(void) { return 0; } (22029-xys)
|
1ms |
6.7 MiB |
|
85 Bytes |
2023-11-5 8:58:59 |
|
郑qr
|
1ms |
7.1 MiB |
C++11 |
86 Bytes |
2024-6-2 13:58:47 |
|
technoblade
|
1ms |
6.7 MiB |
|
94 Bytes |
2023-8-27 9:57:35 |
|
朱老师 (zyp)
|
1ms |
6.5 MiB |
|
107 Bytes |
2023-9-3 14:00:13 |
|
李施城
|
1ms |
7.5 MiB |
|
75 Bytes |
2023-2-11 15:09:11 |
|
朱彦辰
|
1ms |
7 MiB |
C++98(O2) |
103 Bytes |
2024-6-23 10:07:50 |
|
罗嘉懿13
|
1ms |
6.7 MiB |
|
92 Bytes |
2023-9-30 11:19:13 |
|
赵耘毅
|
1ms |
8.1 MiB |
|
89 Bytes |
2023-5-13 20:07:46 |
|
金沙校区-李嘉齐 (李嘉齐)
|
1ms |
6.7 MiB |
|
93 Bytes |
2023-9-2 10:26:12 |
|
张峻瑞89673
|
1ms |
6.7 MiB |
|
91 Bytes |
2023-9-25 16:44:47 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:16:56 |
|
李昊原
|
1ms |
6.5 MiB |
C++20(O2) |
204 Bytes |
2024-7-30 18:11:55 |
|
傀儡师 (zhujingen)
|
1ms |
6.9 MiB |
C++11 |
97 Bytes |
2024-5-22 20:08:05 |
|
金沙校区-周骄阳 (周骄阳)
|
1ms |
6.7 MiB |
|
95 Bytes |
2023-9-2 10:29:15 |
|
黄立信
|
1ms |
7 MiB |
C++98 |
128 Bytes |
2024-6-7 17:38:41 |
|
你干嘛 (唐世睿)
|
1ms |
6.8 MiB |
|
80 Bytes |
2023-10-28 13:29:32 |
|
源著+王新睿 (王新睿)
|
1ms |
6.7 MiB |
|
187 Bytes |
2023-9-28 18:19:52 |
|
郑qr
|
1ms |
7.1 MiB |
C++11 |
86 Bytes |
2024-6-2 13:56:31 |
|
ysf.wlanwq.ZJSWL 1922~1991 (韦舒豪)
|
1ms |
6.8 MiB |
C++98 |
625 Bytes |
2024-8-14 9:17:05 |
|
肖艺勋2
|
1ms |
6.7 MiB |
C++17 |
109 Bytes |
2024-5-23 20:36:27 |
|
葛琮扬
|
1ms |
8 MiB |
|
57 Bytes |
2023-2-16 19:52:37 |
|
中岛敦 (黄麒瑞)
|
1ms |
6.8 MiB |
|
95 Bytes |
2023-9-29 10:25:48 |
|
任润哲
|
1ms |
6.5 MiB |
|
91 Bytes |
2023-9-2 19:25:18 |
|
少羽 (yubohang23002)
|
1ms |
6.7 MiB |
C++11 |
97 Bytes |
2024-6-1 14:02:00 |
|
qinlang
|
1ms |
8.1 MiB |
|
88 Bytes |
2023-5-13 19:18:27 |
|
youhonglin
|
1ms |
8.2 MiB |
|
87 Bytes |
2023-5-5 19:15:00 |
|
超级管理员 (root)
|
1ms |
6.9 MiB |
C++98 |
95 Bytes |
2024-4-17 18:59:26 |
|
时代一校-陈荣添 (陈荣添)
|
1ms |
8 MiB |
|
86 Bytes |
2023-5-13 19:17:01 |
|
洛谷:AIDczy(uid:656765) (chenzeyu)
|
1ms |
8.1 MiB |
|
292 Bytes |
2022-4-9 20:10:07 |
|
王逸辰
|
1ms |
7.2 MiB |
C++98(O2) |
97 Bytes |
2024-5-5 10:12:20 |
|
杨朔
|
1ms |
6.9 MiB |
|
71 Bytes |
2023-10-29 15:48:13 |
|
爱情海校区—沙天一 (沙天一)
|
1ms |
7.4 MiB |
|
88 Bytes |
2023-7-9 8:51:30 |
|
XDEW
|
1ms |
7.1 MiB |
C++98(O2) |
109 Bytes |
2024-6-14 19:41:48 |