最近老是被系统的一些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;
};

STL.h的更多相关文章

  1. 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?

    在查找预编译头时遇到意外的文件结尾.是否忘记了向源中添加“#include "StdAfx.h"”? 右键选择该文件.cpp格式的->属性->预编译头,→ 不使用预编译 ...

  2. STLtoSVG,and SVG to Bmp

    先用这两个工具: Slic3R或者Skeinforge:这个两个工具的作用就是把STL文件切片为叠加的矢量图(SVG格式) 因为SVG是分层的,一层一层的把每层都转换成一张Bmp文件 听说ImageM ...

  3. C++客户端访问WebService VS2008

    VS2008及之后的版本已经不支持使用C++开发WEBService服务了,如果要在VS上开发WEBService,需要使用C#开发语言. 一.gSOAP简介 gSOAP编译工具提供了一个基于SOAP ...

  4. ubuntu 16.04 上使用pybind11进行C++和Python代码相互调用 | Interfacing C++ and Python with pybind11 on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/a41adc1/,欢迎阅读! Interfacing C++ and Python with pybind11 on ubuntu ...

  5. windows 10 上使用pybind11进行C++和Python代码相互调用 | Interfacing C++ and Python with pybind11 on windows 10

    本文首发于个人博客https://kezunlin.me/post/8b9c051d/,欢迎阅读! Interfacing C++ and Python with pybind11 on window ...

  6. VS2015 dlib编译 x64 Release .lib生成

    VS2015 dlib编译 x64 Release >------ 已启动生成: 项目: ZERO_CHECK, 配置: Release x64 ------ > Checking Bui ...

  7. VS2015 dlib编译 x64 Debug .lib生成

    VS2015 dlib编译 x64 Debug >------ 已启动生成: 项目: ZERO_CHECK, 配置: Debug x64 ------ > Checking Build S ...

  8. JMeter接口测试印象篇(win10)

    参考博文1:https://www.cnblogs.com/suim1218/p/9257369.html 参考博文2:https://blog.csdn.net/u011541946/article ...

  9. 混合编程:如何用python11调用C++

    摘要:在实际开发过程中,免不了涉及到混合编程,比如,对于python这种脚本语言,性能还是有限的,在一些对性能要求高的情景下面,还是需要使用c/c++来完成. 那怎样做呢?我们能使用pybind11作 ...

随机推荐

  1. rest_framework视图

    知识预览 视图 回到顶部 视图 使用混合(mixins) 上一节的视图部分:   from rest_framework.views import APIView from rest_framewor ...

  2. 【TencentOS tiny】深度源码分析(7)——事件

    引言 大家在裸机编程中很可能经常用到flag这种变量,用来标志一下某个事件的发生,然后在循环中判断这些标志是否发生,如果是等待多个事件的话,还可能会if((xxx_flag)&&(xx ...

  3. 关于Qt画点及计算机专业基础课程介绍

    在计算机图形图像学中,开始都是先画点,我曾经在汇编上tc2.0上画点,后来是MFC,VB,Qt,Python,我觉得对于计算机专业的选择QT的原因是它是个C系的功能强大庞大的库,可以少写很多代码,但是 ...

  4. Java学习笔记之方法

     前言:如果把所有代码都写到main方法中,后果是什么?    1,结构混乱 不清晰    2,不能重用 方法:规则:方法写在类中,不能写在其它方法中.方法不能嵌套方法 如何定义方法: 访问修饰符 返 ...

  5. go-接口-反射

    接口类型总是代表着某一种类型(即所有实现它的类型)的行为. 一个接口类型的声明通常会包含关键字type.类型名称.关键字interface以及由花括号包裹的若干方法声明. type Animal in ...

  6. Spring Boot构建的Web项目如何在服务端校验表单输入

    本文首发于个人网站:Spring Boot构建的Web项目如何在服务端校验表单输入 这个例子用于演示在Spring Boot应用中如何验证Web 应用的输入,我们将会建立一个简单的Spring MVC ...

  7. 百万年薪python之路 -- HTML标签

    HTML标签 html标签分类 html标签又叫做html元素,它分为块级元素和内联元素(也可以叫做行内元素),都是html规范中的概念. 标题 h1 h2 h3 h4 h5 h6 列表 ol ul ...

  8. 百万年薪python之路 -- 基本数据类型练习

    1.代码敲一遍,然后整理笔记 2.有变量name = "aleX leNb" 完成如下操作: 移除 name 变量对应的值两边的空格,并输出处理结果 name = "al ...

  9. Apollo报错找不到apollo.meta的问题解决方案

    问题描述 Apollo报错,找不到apoll.meta,但是明明配置了apollo-env.properties到apollo-client内了. apollo-env.properties pro. ...

  10. (day27)subprocess模块+粘包问题+struct模块+ UDP协议+socketserver

    目录 昨日回顾 软件开发架构 C/S架构 B/S架构 网络编程 互联网协议 socket套接字 今日内容 一.subprocess模块 二.粘包问题 三.struct模块 四.UDP 五.QQ聊天室 ...