Update IoOperator.h, makefile, StruAndAlgo.h, test.txt, TypeExtend.h, UsedMacro.h files

This commit is contained in:
张硕
2019-12-31 11:11:28 +08:00
parent 6fe2e67322
commit af96ee359d
6 changed files with 5668 additions and 0 deletions

1606
IoOperator.h Normal file

File diff suppressed because it is too large Load Diff

2562
StruAndAlgo.h Normal file

File diff suppressed because it is too large Load Diff

1280
TypeExtend.h Normal file

File diff suppressed because it is too large Load Diff

166
UsedMacro.h Normal file
View File

@@ -0,0 +1,166 @@
#pragma once
//³£Óú궨Òå¿â
//20191111-1705
#include <cstdio>
#include <cassert>
#include <iostream>
#include <type_traits>
#include <utility>
#include <string>
#include <exception>
#include <stdexcept>
//**********
//±êʶ·û²Ù×÷
//**********
#define SYMBOL_STR(id) #id//ת±ä×Ö·û´®
#define CONNECT_SYMBOL_2(str1, str2) str1##str2
#define CONNECT_SYMBOL_3(str1, str2, str3) str1##str2##str3
#define CONNECT_SYMBOL_4(str1, str2, str3, str4) str1##str2##str3##str4
//************
//ÊýÖµÔËËã²Ù×÷
//************
#define NEG_TO(x) ((x) = -(x))//¸³Ïà·´Êý
#define NOT_TO(x) ((x) = !(x))//¸³²¼¶û·Ç
#define INV_TO(x) ((x) = ~(x))//¸³°´Î»È¡·´
#define ABS_OF(x) ((x)>0? (x):-(x))//È¡¾ø¶ÔÖµ
#define ABS_TO(x) ((x) = ABS_OF(x))//¸³¾ø¶ÔÖµ
#define DIS_OF(x, y) (ABS_OF((x)-(y)))//È¡²îÖµ
#define MAX_OF(x, y) ((x)>(y)? (x):(y))//È¡×î´óÖµ
#define MIN_OF(x, y) ((x)<(y)? (x):(y))//È¡×îСֵ
#define MAX_TO(x, lim) ((x) = MAX_OF(x, lim))//¸³×î´óÖµ
#define MIN_TO(x, lim) ((x) = MIN_OF(x, lim))//¸³×îСֵ
#define HIGH_LIMIT(x, lim) MIN_TO(x, lim)//ÉèÖÃÉÏÏÞ
#define LOW_LIMIT(x, lim) MAX_TO(x, lim)//ÉèÖÃÏÂÏÞ
#define RANGE_OF(x, llim, hlim) ((x)<(llim)? (llim): (x)>(hlim)? (hlim):(x))//È¡·¶Î§
#define RANGE_LIMIT(x, llim, hlim) ((x) = RANGE_OF(x, llim, hlim))//ÉèÖ÷¶Î§
#define IS_IN_RANGE(x, llim, hlim) ((x)>=(llim) && (x)<=(hlim))//ÅжÏÊÇ·ñÔÚ·¶Î§ÄÚ
#define IS_IN_ITER_RANGE(x, st, ed) ((x)>=(st) && (x)<(ed))//ÅжÏÊÇ·ñÔÚ·¶Î§ÄÚ£¬ÒÔµü´úÆ÷±ê×¼
#define SQUARE_OF(x) ((x)*(x))//Ç󯽷½
#define SQUARE_TO(x) ((x) = SQUARE_OF(x))//¸³ÖµÆ½·½
//************
//ÔËËãÊ¡ÂÔ²Ù×÷
//************
#define LIST_GO(p, m_p) ((p) = (p)->m_p)//Á´±íÖ¸ÕëÒÆ¶¯
#define LIST_CNNT(p1, m_p1, p2, m_p2) \
(((p1)->m_p1=p2), ((p2)->m_p2=p1))//Ë«ÏòÁ´±íÁ¬½Ó
#define LIST_ADD(p1, m_p1, p2, m_p2, pNew) \
(LIST_CNNT(p1, m_p1, pNew, m_p2), LIST_CNNT(pNew, m_p1, p2, m_p2))//Ë«ÏòÁ´±íÌí¼Ó
#define ARR_SIZE(arr) (sizeof(decltype(arr))\
/sizeof(typename std::remove_extent<decltype(arr)>::type))//ÇóÊý×é´óС
#define ARR_SIZE_ALL(arr) (sizeof(decltype(arr))\
/sizeof(typename std::remove_all_extents<decltype(arr)>::type))//Çó¸ùÊý×é´óС
#define SHOW_BEGIN_END(container) std::begin(container), std::end(container)//ÁгöÈÝÆ÷µÄbeginºÍendº¯Êý
#define O_(id) CONNECT_SYMBOL_2(o_, id)//Ìí¼Óԭʼǰ׺
#define O_INIT(id) id(O_(id))//ʹÓÃǰ׺°æ±¾³õʼ»¯
#define O_INIT_MOVE(id) id(std::move(O_(id)))//ʹÓÃǰ׺°æ±¾Òƶ¯³õʼ»¯
#define O_INIT_FORWARD(id, Ty) id(std::forward<Ty>(O_(id)))//ʹÓÃǰ׺°æ±¾×ª·¢³õʼ»¯
#define O_ASSIGN(id) (id = O_(id))//ʹÓÃǰ׺°æ±¾¸³Öµ
#define O_ASSING_MOVE(id) (id = std::move(O_(id)))//ʹÓÃǰ׺°æ±¾Òƶ¯¸³Öµ
#define O_ASSIGN_FORWARD(id, Ty) (id = std::forward<Ty>(O_(id)))//ʹÓÃǰ׺°æ±¾×ª·¢³õʼ»¯
#define OTHER_INIT(other, mem) mem((other).mem)//ʹÓÃÀà³ÉÔ±³õʼ»¯
#define OTHER_INIT_MOVE(other, mem) mem(std::move(other).mem)//ʹÓÃÀà³ÉÔ±ÒÆ¶¯³õʼ»¯
#define OTHER_INIT_FORWARD(other, mem, Ty) mem(std::forward<Ty>(other).mem)//ʹÓÃÀà³ÉԱת·¢³õʼ»¯
#define OTHER_ASSIGN(other, mem) (mem = (other).mem)//ʹÓÃÀà³ÉÔ±¸³Öµ
#define OTHER_ASSIGN_MOVE(other, mem) (mem = std::move(other).mem)//ʹÓÃÀà³ÉÔ±ÒÆ¶¯¸³Öµ
#define OTHER_ASSIGN_FORWARD(other, mem) (mem = std::forward<Ty>(other).mem)//ʹÓÃÀà³ÉԱת·¢¸³Öµ
//******
//¶àÓï¾ä²Ù×÷
//******
#define CLASS_ASSIGN(Type, other) {\
if(this!=&(other)) {\
this->~Type();\
new(this) Type(other);\
}}//¿½±´¸³Öµ£¬×¢Òâ»á¸²¸ÇÐé±í£¬²»½¨ÒéʹÓÃ
#define CLASS_ASSIGN_MOVE(Type, other) {\
if(this!=&(other)) {\
this->~Type();\
new(this) Type(std::move(other));\
}}//ÒÆ¶¯¸³Öµ£¬×¢Òâ»á¸²¸ÇÐé±í£¬²»½¨ÒéʹÓÃ
#define TEMPLATE_ASSIGN(Type, Typename, arg) {\
this->~Type();\
new(this) Type(std::forward<Typename>(arg));\
}//Ä£°å¸³Öµ£¬×Ô¸³Öµ²»°²È«£¬×¢Òâ»á¸²¸ÇÐé±í£¬²»½¨ÒéʹÓÃ
#define TEMPLATE_PACKET_ASSIGN(Type, Typenames, args) {\
this->~Type();\
new(this) Type(std::forward<Typenames>(args)...);\
}//Ä£°å°ü¸³Öµ£¬×Ô¸³Öµ²»°²È«£¬×¢Òâ»á¸²¸ÇÐé±í£¬²»½¨ÒéʹÓÃ
//******
//ÉùÃ÷²Ù×÷
//******
#define DEFINE_INLINE_VERIABLE(Type, name) \
inline Type &name() \
{\
static Type value;\
return value;\
}//¶¨ÒåÄÚÁª±äÁ¿
#define GET_INLINE_VARIABLE(name) name()//»ñÈ¡ÄÚÁª±äÁ¿

49
makefile Normal file
View File

@@ -0,0 +1,49 @@
#编译器版本
CC = gcc
CXX = g++ -std=c++11
#附加头文件目录
INCS_DIR =
#附加包含库目录
LIBS_DIR =
#附加包含库文件
DEF_LIBS =
STA_LIBS =
DYN_LIBS =
#预定义宏
DEFINE = -D MAKEFILE_ENVIRONMENT
#编译选项
CFLAGS = -g -Wall -O3
#目标生成文件名
TARGETS = DomainDeal
#源文件
C_SRCS = $(wildcard *.c */*.c)
CPP_SRCS = $(wildcard *.cpp */*.cpp)
#中间文件
C_OBJS = $(patsubst %.c,%.o,$(C_SRCS))
CPP_OBJS = $(patsubst %.cpp,%.o,$(CPP_SRCS))
#依赖头文件
HEADS = $(wildcard *.h */*.h *.hpp */*.hpp)
#生成目标
$(TARGETS): $(C_OBJS) $(CPP_OBJS)
$(CXX) -o $@ $(CFLAGS) $(LIBS_DIR) $(C_OBJS) $(CPP_OBJS) \
$(DEF_LIBS) -Wl,-Bstatic $(STA_LIBS) -Wl,-Bdynamic $(DYN_LIBS)
#c生成.o
$(C_OBJS): %.o: %.c $(HEADS)
$(CC) -c $(CFLAGS) $(INCS_DIR) $(DEFINE) $(patsubst %.o,%.c,$@)
#cpp生成.o
$(CPP_OBJS): %.o: %.cpp $(HEADS)
$(CXX) -c $(CFLAGS) $(INCS_DIR) $(DEFINE) $(patsubst %.o,%.cpp,$@)
#清理文件命令
.PHONY: clean
clean:
-rm $(TARGETS) $(C_OBJS) $(CPP_OBJS)
#重构文件命令
.PHONY: rebuild
rebuild: clean $(TARGETS)

5
test.txt Normal file
View File

@@ -0,0 +1,5 @@
this is head line
0 www.baidu.com 3 4 5 6 7 8 9 10 11 12 13 14 etc
0 1 www.google.com 3 4 5 6 7 8 9 10 11 12 13 14
0 1 youku.com 3 4 5 6 7 8 9 10 11 12 13 14 etc