首页 > 其他 > 详细

STL.h

时间:2019-09-05 12:11:05      阅读:79      评论:0      收藏:0      [点我收藏+]

最近老是被系统的一些STL卡到飞起,然后就手打了一个STL.h 库函数还没有打完,以后打新的还会再更,大家也可以使用,顺便帮我找一下bug,然后我再改进!

 1 template< typename RT >class queue
 2 {
 3     public:
 4     RT sta[10000005];
 5     int l,r;
 6     void clear(){l=r=0;}
 7     inline void push(RT x){sta[r++]=x;return ;}
 8     inline void pop(){l++;return ;}
 9     inline RT front(){return sta[l];}
10     inline bool empty(){return r==l;}
11     inline bool size(){return r!=l;}
12 };
13 template< typename RT >class stack
14 {
15     public:
16     RT sta[10000005];
17     int topp;
18     void clear(){topp=0;}
19     inline void push(RT x){sta[++topp]=x;return ;}
20     inline void pop(){topp--;return ;}
21     inline bool empty(){return topp==0;}
22     inline bool size(){return topp;}
23     inline bool top(){return sta[topp];}
24 };
25 template< typename RT >class hash_table
26 {
27     public:
28     int mod;
29     inline void init(int x){mod=x;return ;}
30     int head[100005],vvt[100005],nxt[100005],tot;
31     RT ver[100005];
32     inline void insert(int x,RT ac)
33     {
34         int u=x%mod;
35         for(int i=head[u];i;i=nxt[i])
36         {
37             RT y=ver[i];
38             if(y==ac){vvt[i]++;return ;}
39         }
40         ver[++tot]=ac;
41         nxt[tot]=head[u];
42         head[u]=tot;
43         vvt[tot]++;
44     }
45     inline int query_times(int x,RT ac)
46     {
47         int u=x%mod;
48         for(int i=head[u];i;i=nxt[i])
49         {
50             RT y=ver[i];
51             if(y==ac)return vvt[i];
52         }
53         return 0;
54     }
55 };

//////未完/////////

STL.h

原文:https://www.cnblogs.com/hzoi-lsc/p/11463534.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!