|
chenxiaozhun
|
2ms |
384 KiB |
|
150 Bytes |
2022-4-16 15:47:21 |
|
罗晨睿 (luochenrui)
|
2ms |
384 KiB |
|
149 Bytes |
2022-6-29 13:28:33 |
|
手搓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)
|
2ms |
384 KiB |
|
178 Bytes |
2023-5-13 12:18:55 |
|
maomao
|
2ms |
384 KiB |
|
123 Bytes |
2022-5-25 19:27:30 |
|
杨淇瑞 (杨淇瑞29)
|
2ms |
7 MiB |
|
180 Bytes |
2023-7-18 19:51:25 |
|
新壹街校区-杨轩懿 (杨轩懿1)
|
2ms |
6.7 MiB |
|
160 Bytes |
2023-7-25 13:22:42 |
|
GYZ
|
2ms |
384 KiB |
|
173 Bytes |
2022-5-22 20:36:51 |
|
林小博
|
2ms |
392 KiB |
|
167 Bytes |
2022-5-16 18:51:29 |
|
刘致言
|
2ms |
384 KiB |
|
149 Bytes |
2023-3-11 9:31:13 |
|
黄梓桐 (HuangZiTong)
|
2ms |
384 KiB |
|
144 Bytes |
2022-7-19 17:00:57 |
|
余晨浩 (yuchenhao)
|
2ms |
8.2 MiB |
|
147 Bytes |
2023-8-22 11:32:14 |
|
黄梓轩 (huangzixuan)
|
2ms |
384 KiB |
|
150 Bytes |
2023-5-21 13:52:44 |
|
芒苒忧 (廖迦南)
|
2ms |
384 KiB |
|
177 Bytes |
2022-1-26 20:34:54 |
|
偽艺術家 (chenyanchi22006)
|
2ms |
384 KiB |
|
166 Bytes |
2022-8-15 22:27:29 |
|
colin1112 (墙凌可)
|
2ms |
384 KiB |
|
141 Bytes |
2023-3-11 15:01:01 |
|
wuqi
|
2ms |
6.9 MiB |
|
160 Bytes |
2023-8-7 16:50:28 |
|
05c05-zjk
|
2ms |
384 KiB |
|
167 Bytes |
2023-2-26 13:44:41 |
|
何星震 (Jacob)
|
2ms |
384 KiB |
|
139 Bytes |
2023-2-25 9:45:03 |
|
杨瀚霖 (yanghanlin)
|
2ms |
384 KiB |
|
160 Bytes |
2023-2-5 9:24:37 |
|
huyinuo
|
2ms |
384 KiB |
|
161 Bytes |
2022-3-12 15:08:50 |
|
hst
|
2ms |
384 KiB |
|
151 Bytes |
2022-5-20 20:57:46 |
|
yanglang
|
2ms |
384 KiB |
|
115 Bytes |
2022-10-23 8:28:51 |
|
肖添宇
|
2ms |
384 KiB |
|
147 Bytes |
2022-4-16 17:58:19 |
|
马渝杭 (mayuhang)
|
2ms |
384 KiB |
|
144 Bytes |
2022-8-11 20:00:38 |
|
AC[谭赫奕] (tanheyi)
|
2ms |
384 KiB |
|
165 Bytes |
2023-4-16 9:59:35 |
|
周琪渃
|
2ms |
384 KiB |
|
176 Bytes |
2022-12-7 19:33:46 |
|
经常消失 (小萝卜)
|
2ms |
384 KiB |
|
168 Bytes |
2022-7-15 17:01:50 |
|
德克萨斯做的到吗 (liyangbao)
|
2ms |
384 KiB |
|
158 Bytes |
2022-11-18 22:39:37 |
|
廖海宇在追杀马牌痞 (liaohaiyu22031)
|
2ms |
384 KiB |
|
146 Bytes |
2022-11-11 17:26:22 |
|
邹曜丞 (13983097018)
|
2ms |
384 KiB |
|
136 Bytes |
2023-5-6 19:14:10 |
|
新壹街校区-老师: 黄路 (陈星宇)
|
2ms |
384 KiB |
|
145 Bytes |
2022-9-2 20:19:14 |
|
疯神芭芭脱丝 (李卓修)
|
2ms |
384 KiB |
|
174 Bytes |
2022-1-26 17:25:24 |
|
(张洛诚)
|
2ms |
384 KiB |
|
143 Bytes |
2023-4-17 19:56:26 |
|
张梓辰 (DiaoDesi屌德斯)
|
2ms |
384 KiB |
|
160 Bytes |
2022-9-14 19:43:34 |
|
Randy Marsh (杨子腾)
|
2ms |
384 KiB |
|
184 Bytes |
2022-5-9 20:13:40 |
|
hulang
|
2ms |
384 KiB |
|
208 Bytes |
2022-2-14 18:57:18 |
|
王胤钦 (wangyinqin)
|
2ms |
436 KiB |
|
135 Bytes |
2022-4-16 15:49:08 |
|
luoluonuoya
|
2ms |
384 KiB |
|
147 Bytes |
2022-1-25 16:03:36 |
|
罗翌珂 (dangdang)
|
2ms |
384 KiB |
|
161 Bytes |
2022-8-29 11:57:35 |
|
詹宇航 (zyh7)
|
2ms |
384 KiB |
|
147 Bytes |
2022-7-8 18:03:00 |
|
蓝色妖姬 (jiangpeiyu)
|
2ms |
384 KiB |
|
161 Bytes |
2022-10-1 9:28:21 |
|
SB (mfy01)
|
2ms |
384 KiB |
|
169 Bytes |
2023-2-4 20:07:12 |
|
Yangshenxin (𝒲𝒶𝓉𝑒𝓇)
|
2ms |
392 KiB |
|
207 Bytes |
2022-1-23 18:23:54 |
|
陈星伽
|
2ms |
384 KiB |
|
151 Bytes |
2022-10-1 9:37:46 |
|
longhao
|
2ms |
384 KiB |
|
158 Bytes |
2022-1-24 17:59:51 |
|
jighghjkfkhfdhdfdfdsfsdfsafvmnkbnkbmnlvnmkbvnvb;,.m;,;.;,;kbvlmkbnlmkblnvkmlbnkmlbvkmlbvklmbkmlkblmbnm;,l.,.;,'.,';.[',;.[,kjkoihgfhfgiohifgohifgohiofgihgofhiofgihofgihofgihofgiho;''[;.',m;.',m.;',.;'m,.;';'cv;x'cb'cx;b'cv;b'xc;b'c;b'cvbvc.'bv.//,/vb./vcb./cvbv,c.b,cv.,b.cv,b.vc,bg;hgl;hgl;hg;h;hfg;hl;lf;l;lxc;cln;bvln;vcln;vnl;vbl;vbln;vlv;blnvb;plnp;lplhfljpjh;nlvb;nv;bn;vcvl;nlv;nlv;g;hjhchl;ghfghl;fghl;ltlh;l;hlf;lg;bnlc;;nlv;nbv;nbv;nvb;nlvcnl;xc;blxcb;ll;hg;lhgl;dfl;t;ldy;l;lyl;rewlt493;l;dl;dsflg;lsdlpbpcxobpocvbpopopopreopotpreotertertretert (litingxu)
|
2ms |
384 KiB |
|
127 Bytes |
2023-4-16 16:30:37 |
|
宫保鸡丁 (wxp)
|
2ms |
384 KiB |
|
161 Bytes |
2022-4-16 15:48:13 |
|
NJL (NJlL)
|
2ms |
384 KiB |
|
284 Bytes |
2022-4-10 18:11:51 |
|
Jack
|
2ms |
384 KiB |
|
147 Bytes |
2022-9-2 20:09:32 |
|
pwf
|
2ms |
384 KiB |
|
153 Bytes |
2022-9-2 20:12:38 |
|
ylc
|
2ms |
384 KiB |
|
198 Bytes |
2022-9-2 20:10:53 |
|
凌肯 (lingken22006)
|
2ms |
384 KiB |
|
176 Bytes |
2022-7-31 21:56:39 |
|
pwf
|
2ms |
436 KiB |
|
153 Bytes |
2022-4-16 15:51:12 |
|
yuhaodi
|
2ms |
384 KiB |
|
131 Bytes |
2023-5-13 11:25:35 |
|
繁星 (05c35-zzm)
|
2ms |
384 KiB |
|
167 Bytes |
2022-11-26 10:18:58 |
|
炼狱杏寿郎(的粉粉粉粉粉) (sheijiangwohh)
|
2ms |
384 KiB |
|
240 Bytes |
2022-3-2 18:46:26 |
|
ganlin1
|
2ms |
6.8 MiB |
|
135 Bytes |
2023-7-20 11:34:32 |
|
ylc
|
2ms |
384 KiB |
|
198 Bytes |
2022-4-16 15:53:42 |
|
冒牌陈杰晟【MOD】 (wed)
|
2ms |
384 KiB |
|
102 Bytes |
2022-3-2 17:53:31 |
|
陈杰晟
|
2ms |
384 KiB |
|
177 Bytes |
2022-3-6 15:31:36 |
|
SYC0226
|
2ms |
384 KiB |
|
153 Bytes |
2022-3-20 12:46:19 |
|
yu (赵子瑜)
|
2ms |
384 KiB |
|
165 Bytes |
2022-3-3 20:46:53 |
|
ylc
|
2ms |
432 KiB |
|
198 Bytes |
2022-9-2 20:22:45 |
|
🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕 (bro)
|
2ms |
384 KiB |
|
132 Bytes |
2022-1-25 16:03:44 |
|
yu (赵子瑜)
|
2ms |
384 KiB |
|
165 Bytes |
2022-3-3 20:46:55 |
|
ywh
|
2ms |
384 KiB |
|
149 Bytes |
2022-2-11 13:30:59 |
|
新壹街陈科言 (cky)
|
2ms |
7.2 MiB |
|
185 Bytes |
2023-7-20 14:14:18 |
|
zzzrrrxxx
|
2ms |
6.9 MiB |
|
114 Bytes |
2023-8-19 19:08:01 |
|
火爆肥肠(杨弘毅) (火爆肥肠)
|
2ms |
384 KiB |
|
169 Bytes |
2022-3-19 15:47:30 |
|
yu (赵子瑜)
|
2ms |
384 KiB |
|
165 Bytes |
2022-3-3 20:46:57 |
|
22029-lyh
|
2ms |
328 KiB |
|
154 Bytes |
2023-4-18 19:02:06 |
|
陈红恺 (chk)
|
2ms |
480 KiB |
|
160 Bytes |
2022-9-28 20:52:51 |
|
罗伟杰 (13308275065)
|
2ms |
384 KiB |
|
166 Bytes |
2022-12-17 10:18:31 |
|
heyi
|
2ms |
6.8 MiB |
C++98(O2) |
142 Bytes |
2024-8-10 13:26:19 |
|
11451254188 (22029-mjh)
|
2ms |
384 KiB |
|
171 Bytes |
2022-11-25 18:36:58 |
|
chaikexu
|
2ms |
384 KiB |
|
132 Bytes |
2022-12-3 20:39:47 |
|
蒲梓勋 (puzixun)
|
2ms |
384 KiB |
|
118 Bytes |
2023-1-6 16:58:38 |
|
呵呵呵 (陈思琦)
|
2ms |
384 KiB |
|
134 Bytes |
2022-12-3 16:46:25 |
|
向俊熙 (xiangjunxi23003)
|
2ms |
6.7 MiB |
|
128 Bytes |
2023-9-7 20:55:25 |
|
彭嘉豪 (pengjiahao)
|
2ms |
384 KiB |
|
187 Bytes |
2022-10-26 21:55:43 |
|
TBB (杜昊燃)
|
2ms |
384 KiB |
|
211 Bytes |
2022-4-30 11:27:05 |
|
叶雨昊 (yeyuhao22006)
|
2ms |
384 KiB |
|
141 Bytes |
2022-10-23 20:05:05 |
|
我是撒bi (pyf)
|
2ms |
384 KiB |
|
164 Bytes |
2022-4-16 15:48:53 |
|
22029-zjs
|
2ms |
392 KiB |
|
189 Bytes |
2023-2-11 9:25:44 |
|
hzm
|
2ms |
384 KiB |
|
117 Bytes |
2022-10-1 9:29:20 |
|
wrqwc
|
3ms |
384 KiB |
|
146 Bytes |
2022-9-2 20:25:35 |
|
炸鱼4000+ (dxc)
|
3ms |
6.9 MiB |
|
135 Bytes |
2023-11-12 20:54:54 |
|
没有此人 (akm)
|
3ms |
7.1 MiB |
|
137 Bytes |
2023-12-30 13:38:36 |
|
JOKER (hhy)
|
3ms |
6.9 MiB |
|
116 Bytes |
2023-12-8 20:05:09 |
|
kapurua
|
3ms |
6.9 MiB |
|
127 Bytes |
2024-1-22 17:00:29 |
|
小码王高新校区—刘晨皓 (shishen)
|
4ms |
532 KiB |
|
148 Bytes |
2024-3-15 20:15:09 |
|
A小涂
|
5ms |
320 KiB |
C++17 |
162 Bytes |
2024-10-5 9:30:28 |
|
陈诺
|
5ms |
7.1 MiB |
|
137 Bytes |
2024-1-2 16:23:07 |
|
amr (董子溪)
|
5ms |
7.1 MiB |
|
180 Bytes |
2024-1-17 18:54:37 |
|
新壹街校区-冉睦阳 (冉睦阳)
|
5ms |
7 MiB |
|
139 Bytes |
2023-12-17 12:09:06 |
|
22029-lsl
|
5ms |
368 KiB |
|
161 Bytes |
2022-11-25 18:29:54 |
|
xuniaoyin (徐袅音)
|
5ms |
7.2 MiB |
|
105 Bytes |
2024-1-22 14:50:23 |
|
陈雨泽1
|
5ms |
7 MiB |
|
133 Bytes |
2024-1-16 13:54:38 |
|
shuige
|
7ms |
2.8 MiB |
Python 2 |
55 Bytes |
2023-5-7 10:19:23 |
|
谢博文
|
7ms |
2.8 MiB |
Python 2 |
105 Bytes |
2022-2-19 11:07:40 |