From 4163cf421c152d1b2c928dbf760c8d5af4f1e379 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 20 Mar 2024 23:07:02 +0800 Subject: [PATCH] added SeriesPool.h --- inc/hgl/type/SeriesPool.h | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 inc/hgl/type/SeriesPool.h diff --git a/inc/hgl/type/SeriesPool.h b/inc/hgl/type/SeriesPool.h new file mode 100644 index 0000000..9c8eb75 --- /dev/null +++ b/inc/hgl/type/SeriesPool.h @@ -0,0 +1,75 @@ +#pragma once +//#include + +namespace hgl +{ + /** + * 序号池 + */ + template class SeriesPool + { + //一定要用带BOM头的UTF8存哦!“量”字在一行的最后,会导致编译器报错,认不出来换行符。 + + T max_count; ///<最大数量 + T *series_data; ///<序列数据 + T *end; ///<结束指针 + T *access; ///<访问指针 + + public: + + const int GetMaxCount()const{return max_count;} + + public: + + SeriesPool(const T &count) + { + max_count=count; + series_data=new T[max_count]; + end=series_data+max_count; + access=end; + + { + T *p=series_data; + + for(T i=0;i=end) + return(false); + + *access=s; + ++access; + + return(true); + } + };//template class SeriesPool + + using SeriesInt=SeriesPool; + using SeriesUInt=SeriesPool; + + using SeriesInt64=SeriesPool; + using SeriesUInt64=SeriesPool; +}//namespace hgl