renamed to SortedSet instead of SortedSets

This commit is contained in:
hyzboy 2024-11-02 19:32:32 +08:00
parent 0dad4c5f9e
commit 8dc653b7b1
12 changed files with 40 additions and 34 deletions

View File

@ -1,7 +1,7 @@
#ifndef 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>
namespace hgl
{
@ -31,7 +31,7 @@ namespace hgl
InputEventSource source_type;
SortedSets<InputEvent *> sub_event_proc[size_t(InputEventSource::RANGE_SIZE)];
SortedSet<InputEvent *> sub_event_proc[size_t(InputEventSource::RANGE_SIZE)];
public:

View File

@ -2,7 +2,7 @@
#define HGL_THREAD_INCLUDE
#include<hgl/type/DataType.h>
#include<hgl/type/SortedSets.h>
#include<hgl/type/SortedSet.h>
#include<hgl/type/String.h>
#include<hgl/thread/ThreadMutex.h>
#include<hgl/log/LogInfo.h>
@ -121,7 +121,7 @@ namespace hgl
{
protected:
SortedSets<THREAD *> thread_set;
SortedSet<THREAD *> thread_set;
public:

View File

@ -2,7 +2,7 @@
#include<hgl/type/DataArray.h>
#include<hgl/type/Stack.h>
#include<hgl/type/SortedSets.h>
#include<hgl/type/SortedSet.h>
namespace hgl
{
@ -11,7 +11,7 @@ namespace hgl
*/
class ActiveIDManager
{
SortedSets<int> active_list; ///<活跃ID列表
SortedSet<int> active_list; ///<活跃ID列表
Stack<int> idle_list; ///<闲置ID列表
int id_count;

View File

@ -1,6 +1,6 @@
#pragma once
#include<hgl/type/SortedSets.h>
#include<hgl/type/SortedSet.h>
#include<hgl/type/Map.h>
#include<hgl/io/TextOutputStream.h>
@ -74,7 +74,7 @@ namespace hgl
DataArray<SC> str_data; ///<字符串数据
SortedSets<ConstStringView<SC>> str_set; ///<字符串集合
SortedSet<ConstStringView<SC>> str_set; ///<字符串集合
List<ConstStringView<SC>> str_list; ///<字符串列表
Map<int,size_t> str_offset_map; ///<字符串映射

View File

@ -626,8 +626,8 @@ namespace hgl
result_list.SetCount(result);
}
//int64 Intersection (SortedSets<T> &result,const SortedSets<T> &sets); ///<取得与指定合集的交集
//int64 Intersection (const SortedSets<T> &set); ///<取得与指定合集的交集数量
//int64 Intersection (SortedSet<T> &result,const SortedSet<T> &sets); ///<取得与指定合集的交集
//int64 Intersection (const SortedSet<T> &set); ///<取得与指定合集的交集数量
///**
// * 取得与指定交集is的合集但排斥cs合集中的数据
@ -636,9 +636,9 @@ namespace hgl
// * @param cs 求排斥的合集
// * @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 要计算交集的数据集
// * @return 交集数量
// */
//int64 Intersection(SortedSets<T> &result,const SortedSets<T> &list)
//int64 Intersection(SortedSet<T> &result,const SortedSet<T> &list)
//{
// if(data_list.GetCount()<=0)
// return(0);
@ -663,7 +663,7 @@ namespace hgl
// return result.GetCount();
//}
//int64 Intersection(const SortedSets<T> &list)
//int64 Intersection(const SortedSet<T> &list)
//{
// if(data_list.GetCount()<=0)
// return(0);
@ -685,7 +685,7 @@ namespace hgl
// 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)
// return(0);
@ -727,6 +727,6 @@ namespace hgl
// return count;
//}
//int64 Clear (const SortedSets<T> &clear_sets); ///<清除指定合集中所有数据
//int64 Clear (const SortedSet<T> &clear_sets); ///<清除指定合集中所有数据
};//template<typename T> class DataArray
}//namespace hgl

View File

@ -1,7 +1,7 @@
#pragma once
#include<hgl/type/DataStackPool.h>
#include<hgl/type/SortedSets.h>
#include<hgl/type/SortedSet.h>
namespace hgl
{
@ -42,7 +42,7 @@ namespace hgl
DataStackPool<UserNode> ud_pool; ///<用户数据占用信息池
SortedSets<UserNode *> ud_set; ///<用户数据占用合集
SortedSet<UserNode *> ud_set; ///<用户数据占用合集
#ifdef _DEBUG
public:

View File

@ -1,5 +1,5 @@
#pragma once
#include<hgl/type/SortedSets.h>
#include<hgl/type/SortedSet.h>
#include<random>
namespace hgl
@ -79,7 +79,7 @@ namespace hgl
if(min_value==0&&max_value==0)
max_value=max_count-1;
SortedSets<T> ss; //使用排序集合用来储存随机序号
SortedSet<T> ss; //使用排序集合用来储存随机序号
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<T> dis(min_value,max_value);

View File

@ -8,7 +8,7 @@ namespace hgl
* </br>
* Add函数ListSortedSets</br>
*/
template<typename T> class SortedSets
template<typename T> class SortedSet
{
protected:
@ -38,8 +38,8 @@ namespace hgl
public:
SortedSets()=default;
virtual ~SortedSets()=default;
SortedSet()=default;
virtual ~SortedSet()=default;
void SetCount (int64 count){data_list.SetCount(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 GetLast (T &data){return hgl_cpy(data,*last());} ///<取得最后面一个数据
void operator =(const SortedSets<T> &set){data_list=set.data_list;} ///<等号操作符重载
};//template<typename T> class SortedSets
void operator =(const SortedSet<T> &set){data_list=set.data_list;} ///<等号操作符重载
};//template<typename T> class SortedSet
}//namespace hgl

View File

@ -13,11 +13,12 @@ namespace hgl
public:
const ObjectSimpleInfo &GetObjectSimpleInfo () const noexcept { return object_base_info; } ///<获取对象简单信息
const ObjectBaseInfo & GetObjectBaseInfo () const noexcept { return object_base_info; } ///<获取对象基本信息
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; } ///<获取对象的序列号
protected:
@ -32,6 +33,10 @@ namespace hgl
virtual ~Object()=default;
virtual void Deinitailize()=0;
virtual bool CheckType()
{
}
};//class Object
template<typename T> class DefaultObjectManager;
@ -50,7 +55,7 @@ namespace hgl
\
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>
SafePtr<T> &operator=(SafePtr<OT> &spd)
{
if(T::StaticHashCode()!=OT.StaticHashCode())
if(T::StaticTypeHash()!=OT::StaticTypeHash())
{
Release();
return *this;

View File

@ -23,7 +23,7 @@ namespace hgl
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 size_t GetCount()const{return object_count;}
@ -88,7 +88,7 @@ namespace hgl
{
ObjectBaseInfo obi
{
.hash_code =GetHashCode(),
.hash_code =GetTypeHash(),
.object_manager =this,
.serial_number =AcquireSerialNumber(),
.source_code_location=scl

View File

@ -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(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/ObjectAllocator.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)
SET(BASE_TIME_SOURCE_FILES Time/DateTime.cpp
Time/TimeCount.cpp
Time/TimeVal.cpp)
Time/TimeCount.cpp
Time/TimeVal.cpp)
SOURCE_GROUP("Time\\Header Files" FILES ${BASE_TIME_HEADER_FILES})
SOURCE_GROUP("Time\\Source Files" FILES ${BASE_TIME_SOURCE_FILES})

View File

@ -24,7 +24,7 @@ namespace hgl
if(!om)
return(false);
const size_t hc=om->GetHashCode();
const size_t hc=om->GetTypeHash();
auto *omm=GetObjectManagerMap();
@ -43,7 +43,7 @@ namespace hgl
if(!om)
return;
const size_t hc=om->GetHashCode();
const size_t hc=om->GetTypeHash();
auto *omm=GetObjectManagerMap();