renamed to SortedSet instead of SortedSets
This commit is contained in:
parent
0dad4c5f9e
commit
8dc653b7b1
@ -1,7 +1,7 @@
|
|||||||
#ifndef HGL_IO_INPUT_EVENT_INCLUDE
|
#ifndef HGL_IO_INPUT_EVENT_INCLUDE
|
||||||
#define HGL_IO_INPUT_EVENT_INCLUDE
|
#define HGL_IO_INPUT_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/io/event/InputEventSource.h>
|
#include<hgl/io/event/InputEventSource.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ namespace hgl
|
|||||||
|
|
||||||
InputEventSource source_type;
|
InputEventSource source_type;
|
||||||
|
|
||||||
SortedSets<InputEvent *> sub_event_proc[size_t(InputEventSource::RANGE_SIZE)];
|
SortedSet<InputEvent *> sub_event_proc[size_t(InputEventSource::RANGE_SIZE)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define HGL_THREAD_INCLUDE
|
#define HGL_THREAD_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/DataType.h>
|
#include<hgl/type/DataType.h>
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/type/String.h>
|
#include<hgl/type/String.h>
|
||||||
#include<hgl/thread/ThreadMutex.h>
|
#include<hgl/thread/ThreadMutex.h>
|
||||||
#include<hgl/log/LogInfo.h>
|
#include<hgl/log/LogInfo.h>
|
||||||
@ -121,7 +121,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SortedSets<THREAD *> thread_set;
|
SortedSet<THREAD *> thread_set;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include<hgl/type/DataArray.h>
|
#include<hgl/type/DataArray.h>
|
||||||
#include<hgl/type/Stack.h>
|
#include<hgl/type/Stack.h>
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
class ActiveIDManager
|
class ActiveIDManager
|
||||||
{
|
{
|
||||||
SortedSets<int> active_list; ///<活跃ID列表
|
SortedSet<int> active_list; ///<活跃ID列表
|
||||||
Stack<int> idle_list; ///<闲置ID列表
|
Stack<int> idle_list; ///<闲置ID列表
|
||||||
|
|
||||||
int id_count;
|
int id_count;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/type/Map.h>
|
#include<hgl/type/Map.h>
|
||||||
#include<hgl/io/TextOutputStream.h>
|
#include<hgl/io/TextOutputStream.h>
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace hgl
|
|||||||
|
|
||||||
DataArray<SC> str_data; ///<字符串数据
|
DataArray<SC> str_data; ///<字符串数据
|
||||||
|
|
||||||
SortedSets<ConstStringView<SC>> str_set; ///<字符串集合
|
SortedSet<ConstStringView<SC>> str_set; ///<字符串集合
|
||||||
|
|
||||||
List<ConstStringView<SC>> str_list; ///<字符串列表
|
List<ConstStringView<SC>> str_list; ///<字符串列表
|
||||||
Map<int,size_t> str_offset_map; ///<字符串映射
|
Map<int,size_t> str_offset_map; ///<字符串映射
|
||||||
|
@ -626,8 +626,8 @@ namespace hgl
|
|||||||
result_list.SetCount(result);
|
result_list.SetCount(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//int64 Intersection (SortedSets<T> &result,const SortedSets<T> &sets); ///<取得与指定合集的交集
|
//int64 Intersection (SortedSet<T> &result,const SortedSet<T> &sets); ///<取得与指定合集的交集
|
||||||
//int64 Intersection (const SortedSets<T> &set); ///<取得与指定合集的交集数量
|
//int64 Intersection (const SortedSet<T> &set); ///<取得与指定合集的交集数量
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * 取得与指定交集is的合集,但排斥cs合集中的数据
|
// * 取得与指定交集is的合集,但排斥cs合集中的数据
|
||||||
@ -636,9 +636,9 @@ namespace hgl
|
|||||||
// * @param cs 求排斥的合集
|
// * @param cs 求排斥的合集
|
||||||
// * @return 结果数量
|
// * @return 结果数量
|
||||||
// */
|
// */
|
||||||
//int64 Intersection (SortedSets<T> &result,const SortedSets<T> &is,const SortedSets<T> &cs);
|
//int64 Intersection (SortedSet<T> &result,const SortedSet<T> &is,const SortedSet<T> &cs);
|
||||||
|
|
||||||
//int64 Difference (const SortedSets<T> &is); ///<求差集数量
|
//int64 Difference (const SortedSet<T> &is); ///<求差集数量
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * 求当前合集与另一个数据集的交集
|
// * 求当前合集与另一个数据集的交集
|
||||||
@ -646,7 +646,7 @@ namespace hgl
|
|||||||
// * @param list 要计算交集的数据集
|
// * @param list 要计算交集的数据集
|
||||||
// * @return 交集数量
|
// * @return 交集数量
|
||||||
// */
|
// */
|
||||||
//int64 Intersection(SortedSets<T> &result,const SortedSets<T> &list)
|
//int64 Intersection(SortedSet<T> &result,const SortedSet<T> &list)
|
||||||
//{
|
//{
|
||||||
// if(data_list.GetCount()<=0)
|
// if(data_list.GetCount()<=0)
|
||||||
// return(0);
|
// return(0);
|
||||||
@ -663,7 +663,7 @@ namespace hgl
|
|||||||
// return result.GetCount();
|
// return result.GetCount();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//int64 Intersection(const SortedSets<T> &list)
|
//int64 Intersection(const SortedSet<T> &list)
|
||||||
//{
|
//{
|
||||||
// if(data_list.GetCount()<=0)
|
// if(data_list.GetCount()<=0)
|
||||||
// return(0);
|
// return(0);
|
||||||
@ -685,7 +685,7 @@ namespace hgl
|
|||||||
// return count;
|
// return count;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//int64 Intersection(SortedSets<T> &result,const SortedSets<T> &il,const SortedSets<T> &cl)
|
//int64 Intersection(SortedSet<T> &result,const SortedSet<T> &il,const SortedSet<T> &cl)
|
||||||
//{
|
//{
|
||||||
// if(data_list.GetCount()<=0)
|
// if(data_list.GetCount()<=0)
|
||||||
// return(0);
|
// return(0);
|
||||||
@ -727,6 +727,6 @@ namespace hgl
|
|||||||
// return count;
|
// return count;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//int64 Clear (const SortedSets<T> &clear_sets); ///<清除指定合集中所有数据
|
//int64 Clear (const SortedSet<T> &clear_sets); ///<清除指定合集中所有数据
|
||||||
};//template<typename T> class DataArray
|
};//template<typename T> class DataArray
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/type/DataStackPool.h>
|
#include<hgl/type/DataStackPool.h>
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ namespace hgl
|
|||||||
|
|
||||||
DataStackPool<UserNode> ud_pool; ///<用户数据占用信息池
|
DataStackPool<UserNode> ud_pool; ///<用户数据占用信息池
|
||||||
|
|
||||||
SortedSets<UserNode *> ud_set; ///<用户数据占用合集
|
SortedSet<UserNode *> ud_set; ///<用户数据占用合集
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
public:
|
public:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include<hgl/type/SortedSets.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<random>
|
#include<random>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
@ -79,7 +79,7 @@ namespace hgl
|
|||||||
if(min_value==0&&max_value==0)
|
if(min_value==0&&max_value==0)
|
||||||
max_value=max_count-1;
|
max_value=max_count-1;
|
||||||
|
|
||||||
SortedSets<T> ss; //使用排序集合用来储存随机序号
|
SortedSet<T> ss; //使用排序集合用来储存随机序号
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 gen(rd());
|
std::mt19937 gen(rd());
|
||||||
std::uniform_int_distribution<T> dis(min_value,max_value);
|
std::uniform_int_distribution<T> dis(min_value,max_value);
|
||||||
|
@ -8,7 +8,7 @@ namespace hgl
|
|||||||
* 集合数据列表中不允许数据出现重复性,同时它会将数据排序</br>
|
* 集合数据列表中不允许数据出现重复性,同时它会将数据排序</br>
|
||||||
* 我们删除了批量添加数据的Add函数,因为每一次添加数据都会导致一次插入,这样效率太低了。我们建议将数据全部添加到List,再转换为SortedSets。</br>
|
* 我们删除了批量添加数据的Add函数,因为每一次添加数据都会导致一次插入,这样效率太低了。我们建议将数据全部添加到List,再转换为SortedSets。</br>
|
||||||
*/
|
*/
|
||||||
template<typename T> class SortedSets
|
template<typename T> class SortedSet
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SortedSets()=default;
|
SortedSet()=default;
|
||||||
virtual ~SortedSets()=default;
|
virtual ~SortedSet()=default;
|
||||||
|
|
||||||
void SetCount (int64 count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理
|
void SetCount (int64 count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理
|
||||||
void PreAlloc (int64 count){data_list.Alloc(count);} ///<预分配指定数量的数据空间
|
void PreAlloc (int64 count){data_list.Alloc(count);} ///<预分配指定数量的数据空间
|
||||||
@ -173,6 +173,6 @@ namespace hgl
|
|||||||
bool GetFirst (T &data){return hgl_cpy(data,*begin());} ///<取得最前面一个数据
|
bool GetFirst (T &data){return hgl_cpy(data,*begin());} ///<取得最前面一个数据
|
||||||
bool GetLast (T &data){return hgl_cpy(data,*last());} ///<取得最后面一个数据
|
bool GetLast (T &data){return hgl_cpy(data,*last());} ///<取得最后面一个数据
|
||||||
|
|
||||||
void operator =(const SortedSets<T> &set){data_list=set.data_list;} ///<等号操作符重载
|
void operator =(const SortedSet<T> &set){data_list=set.data_list;} ///<等号操作符重载
|
||||||
};//template<typename T> class SortedSets
|
};//template<typename T> class SortedSet
|
||||||
}//namespace hgl
|
}//namespace hgl
|
@ -13,11 +13,12 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
const ObjectSimpleInfo &GetObjectSimpleInfo () const noexcept { return object_base_info; } ///<获取对象简单信息
|
||||||
const ObjectBaseInfo & GetObjectBaseInfo () const noexcept { return object_base_info; } ///<获取对象基本信息
|
const ObjectBaseInfo & GetObjectBaseInfo () const noexcept { return object_base_info; } ///<获取对象基本信息
|
||||||
|
|
||||||
ObjectManager * GetObjectManager () noexcept { return object_base_info.object_manager; } ///<获取对象管理器
|
ObjectManager * GetObjectManager () noexcept { return object_base_info.object_manager; } ///<获取对象管理器
|
||||||
|
|
||||||
const size_t GetHashCode () const noexcept { return object_base_info.hash_code; } ///<获取对象数据类型的hash值
|
const size_t GetTypeHash () const noexcept { return object_base_info.hash_code; } ///<获取对象数据类型的hash值
|
||||||
const size_t GetSerialNumber () const noexcept { return object_base_info.serial_number; } ///<获取对象的序列号
|
const size_t GetSerialNumber () const noexcept { return object_base_info.serial_number; } ///<获取对象的序列号
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -32,6 +33,10 @@ namespace hgl
|
|||||||
virtual ~Object()=default;
|
virtual ~Object()=default;
|
||||||
|
|
||||||
virtual void Deinitailize()=0;
|
virtual void Deinitailize()=0;
|
||||||
|
|
||||||
|
virtual bool CheckType()
|
||||||
|
{
|
||||||
|
}
|
||||||
};//class Object
|
};//class Object
|
||||||
|
|
||||||
template<typename T> class DefaultObjectManager;
|
template<typename T> class DefaultObjectManager;
|
||||||
@ -50,7 +55,7 @@ namespace hgl
|
|||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
\
|
\
|
||||||
static const size_t StaticHashCode() noexcept {return GetTypeHash<class_name>();} \
|
static const size_t StaticTypeHash() noexcept {return hgl::GetTypeHash<class_name>();} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +155,7 @@ namespace hgl
|
|||||||
template<typename OT>
|
template<typename OT>
|
||||||
SafePtr<T> &operator=(SafePtr<OT> &spd)
|
SafePtr<T> &operator=(SafePtr<OT> &spd)
|
||||||
{
|
{
|
||||||
if(T::StaticHashCode()!=OT.StaticHashCode())
|
if(T::StaticTypeHash()!=OT::StaticTypeHash())
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -23,7 +23,7 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const size_t GetHashCode()const{return object_hash_code;}
|
const size_t GetTypeHash()const{return object_hash_code;}
|
||||||
const char * GetTypename()const{return object_type_name;}
|
const char * GetTypename()const{return object_type_name;}
|
||||||
const size_t GetCount()const{return object_count;}
|
const size_t GetCount()const{return object_count;}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
ObjectBaseInfo obi
|
ObjectBaseInfo obi
|
||||||
{
|
{
|
||||||
.hash_code =GetHashCode(),
|
.hash_code =GetTypeHash(),
|
||||||
.object_manager =this,
|
.object_manager =this,
|
||||||
.serial_number =AcquireSerialNumber(),
|
.serial_number =AcquireSerialNumber(),
|
||||||
.source_code_location=scl
|
.source_code_location=scl
|
||||||
|
@ -58,6 +58,7 @@ SET(SYSTEM_INFO_SOURCE ${CORE_PLATFORM_INCLUDE_PATH}/SystemInfo.h
|
|||||||
SET(MATH_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/math)
|
SET(MATH_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/math)
|
||||||
|
|
||||||
SET(BASE_OBJECT_HEADER_FILES ${TYPE_INCLUDE_PATH}/object/ObjectBaseInfo.h
|
SET(BASE_OBJECT_HEADER_FILES ${TYPE_INCLUDE_PATH}/object/ObjectBaseInfo.h
|
||||||
|
${TYPE_INCLUDE_PATH}/object/ObjectRelation.h
|
||||||
${TYPE_INCLUDE_PATH}/object/Object.h
|
${TYPE_INCLUDE_PATH}/object/Object.h
|
||||||
${TYPE_INCLUDE_PATH}/object/ObjectAllocator.h
|
${TYPE_INCLUDE_PATH}/object/ObjectAllocator.h
|
||||||
${TYPE_INCLUDE_PATH}/object/ObjectManager.h
|
${TYPE_INCLUDE_PATH}/object/ObjectManager.h
|
||||||
@ -221,8 +222,8 @@ SET(BASE_TIME_HEADER_FILES ${TYPE_INCLUDE_PATH}/DateTime.h
|
|||||||
${CMCORE_ROOT_INCLUDE_PATH}/hgl/Time.h)
|
${CMCORE_ROOT_INCLUDE_PATH}/hgl/Time.h)
|
||||||
|
|
||||||
SET(BASE_TIME_SOURCE_FILES Time/DateTime.cpp
|
SET(BASE_TIME_SOURCE_FILES Time/DateTime.cpp
|
||||||
Time/TimeCount.cpp
|
Time/TimeCount.cpp
|
||||||
Time/TimeVal.cpp)
|
Time/TimeVal.cpp)
|
||||||
|
|
||||||
SOURCE_GROUP("Time\\Header Files" FILES ${BASE_TIME_HEADER_FILES})
|
SOURCE_GROUP("Time\\Header Files" FILES ${BASE_TIME_HEADER_FILES})
|
||||||
SOURCE_GROUP("Time\\Source Files" FILES ${BASE_TIME_SOURCE_FILES})
|
SOURCE_GROUP("Time\\Source Files" FILES ${BASE_TIME_SOURCE_FILES})
|
||||||
|
@ -24,7 +24,7 @@ namespace hgl
|
|||||||
if(!om)
|
if(!om)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const size_t hc=om->GetHashCode();
|
const size_t hc=om->GetTypeHash();
|
||||||
|
|
||||||
auto *omm=GetObjectManagerMap();
|
auto *omm=GetObjectManagerMap();
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace hgl
|
|||||||
if(!om)
|
if(!om)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const size_t hc=om->GetHashCode();
|
const size_t hc=om->GetTypeHash();
|
||||||
|
|
||||||
auto *omm=GetObjectManagerMap();
|
auto *omm=GetObjectManagerMap();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user