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

 template< typename RT >class queue
{
public:
RT sta[];
int l,r;
void clear(){l=r=;}
inline void push(RT x){sta[r++]=x;return ;}
inline void pop(){l++;return ;}
inline RT front(){return sta[l];}
inline bool empty(){return r==l;}
inline bool size(){return r!=l;}
};
template< typename RT >class stack
{
public:
RT sta[];
int topp;
void clear(){topp=;}
inline void push(RT x){sta[++topp]=x;return ;}
inline void pop(){topp--;return ;}
inline bool empty(){return topp==;}
inline bool size(){return topp;}
inline bool top(){return sta[topp];}
};
template< typename RT >class hash_table
{
public:
int mod;
inline void init(int x){mod=x;return ;}
int head[],vvt[],nxt[],tot;
RT ver[];
inline void insert(int x,RT ac)
{
int u=x%mod;
for(int i=head[u];i;i=nxt[i])
{
RT y=ver[i];
if(y==ac){vvt[i]++;return ;}
}
ver[++tot]=ac;
nxt[tot]=head[u];
head[u]=tot;
vvt[tot]++;
}
inline int query_times(int x,RT ac)
{
int u=x%mod;
for(int i=head[u];i;i=nxt[i])
{
RT y=ver[i];
if(y==ac)return vvt[i];
}
return ;
}
};

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

2019.9.23 UPDATE

更新了queue和stack的大小参数和一些骚操作!

hash_table 没有更新!

 //#include<iostream>
//#include<cstdio>
//#include<cstdlib>
//#include<algorithm>
//using namespace std; //make by lsc; %%%stl
template<typename RT,int MAXN>
class stack
{
public:
RT sta[MAXN];int topp;
inline void clear(){topp=;return ;}
inline void init(){topp=;return ;}
inline void push(RT x){sta[++topp]=x;return ;}
inline int size(){return topp;}
inline bool empty(){return topp;}
inline int bottom(){if(topp==)return -(<<);else return sta[];}
inline int num(RT x){return sta[x];}
inline void sort_stack(RT x){sort(sta+,sta+topp+);if(x)return ;else reverse(sta+,sta+topp+);return ;}//如果x==1,从小到大,else less;
/*
if struct sort please make function!
*/
};
template<typename RT,int MAXN>
class queue
{
public:
#define re register
RT sta[MAXN];
int fr,back;
inline void init(){fr=;back=;}
inline void push(re RT x){sta[++back]=x;return ;}
inline void pop(){fr++;return ;}
inline RT front(){return sta[fr];}
inline bool empty(){if(back>=fr)return ;else return ;}
inline bool size(){if(back<=fr)return ;else return ;}
inline void sort_queue(RT x){sort(sta+back,sta+fr+);if(x)return ;else reverse(sta+back,sta+fr+);return ;}
};

UPDATE 新版本!

 /*
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
*/ //make by lsc; %%%stl
template<typename RT,int MAXN>
class stack
{
public:
RT sta[MAXN];int topp;
inline void clear(){topp=;return ;}
inline void init(){topp=;return ;}
inline void push(RT x){sta[++topp]=x;return ;}
inline int size(){return topp;}
inline bool empty(){return topp;}
inline int bottom(){if(topp==)return -(<<);else return sta[];}
inline int num(RT x){return sta[x];}
inline void pop(){topp--;if(topp<)topp=;return ;}
inline void sort_stack(RT x){sort(sta+,sta+topp+);if(x)return ;else reverse(sta+,sta+topp+);return ;}//如果x==1,从小到大,else less;
/*
if struct sort please make function!
*/
};
template<typename RT,int MAXN>
class queue
{
public:
#define re register
RT sta[MAXN];
int fr,back;
inline void init(){fr=;back=;}
inline void push(re RT x){sta[++back]=x;return ;}
inline void pop(){fr++;return ;}
inline RT front(){return sta[fr];}
inline bool empty(){if(back>=fr)return ;else return ;}
inline bool size(){if(back<=fr)return ;else return ;}
inline void sort_queue(RT x){sort(sta+back,sta+fr+);if(x)return ;else reverse(sta+back,sta+fr+);return ;}
}; template<typename RT,int MAXN>
class priority_queue
{
public:
RT q[MAXN];int sz;
priority_queue(){sz=;}
inline void push(int x)
{
q[++sz]=x;
for(int i=sz,j=i>>;j;i=j,j>>=)
if(q[j]>q[i])swap(q[j],q[i]);
}
inline void pop()
{
q[]=q[sz--];
for(int i=,j=i<<;j<=sz;i=j,j<<=)
{
if((j|)<=sz&&q[j|]<q[j])j=j|;
if(q[i]>q[j])swap(q[i],q[j]);
else break;
}
}
inline RT top(){return q[];}
};
//UPDATE 2019.9.23 pair 未经过测试!
template<typename RT,typename RE>
class pair
{
public:
RT first;RE second;
pair(){first=,second=;}
inline void make_pair(RT a,RE b){first=a,second=b;return ;}
/*
THIS FUNCTION THE DIRECTOR DIDN'T TRUST IT ,SO THE THINGS AFTER YOU USE IT ONLY YOU BEAR!
*/
};

UPDATE 2019.9.26 整理了一下,但没有测试!

 /*
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
*/ //make by lsc; %%%stl
template<typename RT,int MAXN>
class stack
{
public:
RT sta[MAXN];int topp;
inline void clear(){topp=;return ;}
inline void init(){topp=;return ;}
inline void push(RT x){sta[++topp]=x;return ;}
inline int size(){return topp;}
inline bool empty(){return topp;}
inline int bottom(){if(topp==)return -(<<);else return sta[];}
inline int num(RT x){return sta[x];}
inline void pop(){topp--;if(topp<)topp=;return ;}
inline void sort_stack(RT x){sort(sta+,sta+topp+);if(x)return ;else reverse(sta+,sta+topp+);return ;}//如果x==1,从小到大,else less;
/*
if struct sort please make function!
*/
};
template<typename RT,int MAXN>
class queue
{
public:
#define re register
RT sta[MAXN];
int fr,back;
inline void init(){fr=;back=;}
inline void push(re RT x){sta[++back]=x;return ;}
inline void pop(){fr++;return ;}
inline RT front(){return sta[fr];}
inline bool empty(){if(back>=fr)return ;else return ;}
inline bool size(){if(back<=fr)return ;else return ;}
inline void sort_queue(RT x){sort(sta+back,sta+fr+);if(x)return ;else reverse(sta+back,sta+fr+);return ;}
}; template<typename RT,int MAXN>
class priority_queue
{
public:
RT q[MAXN];int sz;
priority_queue(){sz=;}
inline void push(int x)
{
q[++sz]=x;
for(int i=sz,j=i>>;j;i=j,j>>=)
if(q[j]>q[i])swap(q[j],q[i]);
}
inline void pop()
{
q[]=q[sz--];
for(int i=,j=i<<;j<=sz;i=j,j<<=)
{
if((j|)<=sz&&q[j|]<q[j])j=j|;
if(q[i]>q[j])swap(q[i],q[j]);
else break;
}
}
inline RT top(){return q[];}
}; //UPDATE 2019.9.23 pair 未经过测试!
template<typename RT,typename RE>
class pair
{
public:
RT first;RE second;
pair(){first=,second=;}
inline void make_pair(RT a,RE b){first=a,second=b;return ;}
/*
THIS FUNCTION THE DIRECTOR DIDN'T TRUST IT ,SO THE THINGS AFTER YOU USE IT ONLY YOU BEAR!
*/
}; template< typename RT >class hash_table
{
public:
int mod;
inline void init(int x){mod=x;return ;}
int head[],vvt[],nxt[],tot;
RT ver[];
inline void insert(int x,RT ac)
{
int u=x%mod;
for(int i=head[u];i;i=nxt[i])
{
RT y=ver[i];
if(y==ac){vvt[i]++;return ;}
}
ver[++tot]=ac;
nxt[tot]=head[u];
head[u]=tot;
vvt[tot]++;
}
inline int query_times(int x,RT ac)
{
int u=x%mod;
for(int i=head[u];i;i=nxt[i])
{
RT y=ver[i];
if(y==ac)return vvt[i];
}
return ;
}
};
//2019.9.26 UPDATE
//lower_bound but didn't test ,you can test it ,but not int exam!
//I dont't konw if it has bugs!
template<typename RT,typename RE>
RE lower_bound(RT *a,RE l,RE r)
{
while(l<r)
{
int mid=(l+r)>>;
if(a[mid]>=r)r=mid;
else l=mid+;
}
return l;
};

最新文章

  1. Child &lt;- many-to-one -&gt;Parent
  2. Android按需添加Google Play服务
  3. SWFUpload简介及中文参考手册(share)
  4. 在yii2验证之前执行一些额外自定义验证
  5. 【转】WordPress转PHPCMS策略-数据库完美转换
  6. do-while语句
  7. ssh连接慢的问题的解决?
  8. Magento修改邮件模板内容
  9. iostream/fstream中的输入输出流指针的绑定,tie函数的使用。
  10. 修改docker默认172.17网段
  11. .net中用到的一些方法
  12. json介绍及简单示例
  13. php过滤提交数据 防止sql注入攻击
  14. ajaxFileUpload只能上传一次,和上传同名图片不能上传等bug问题
  15. 项目实战02:nginx 反向代理负载均衡、动静分离和缓存的实现
  16. [转载]String.Empty、string=”” 和null的区别
  17. Oracle 导出错误 EXP-00000~EXP-00107
  18. bzoj 1188
  19. ASP.NET MVC:4 Ways To Prevent Duplicate Form Submission(转载)
  20. iptable 限制ip访问

热门文章

  1. 使用TryGetComponent取代GetComponent以避免Editor中的内存分配
  2. Maven项目下使用log4j
  3. python-Flask模版注入攻击SSTI(python沙盒逃逸)
  4. Msfvenom命令总结大全
  5. 关于用gulp合并压缩seaJs模块
  6. Redis 消息队列的实现
  7. Vue学习系列(三)——基本指令
  8. java代码实现MD5加密及验证方法
  9. 第一章、Python环境搭建
  10. 3D切割轮播图