Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ff312dd56b | ||
![]() |
dd5d39bb1d | ||
![]() |
e7e708ad8f | ||
![]() |
1116412c0a | ||
![]() |
6ee11e324c | ||
![]() |
61110f5af9 | ||
![]() |
1fdb271174 | ||
![]() |
6b5dd60ea3 |
42
README.md
42
README.md
@ -6,29 +6,29 @@
|
||||
### 详细梗概
|
||||
该库以模块化的方式来组织,主要模块包括内存管理模块、高级数据结构模块、文件储存模块、网络传输模块、子程序管理模块、回调机制实现模块、错误管理模块、在主要模块还会被分为几个小模块。模块之间有对应的依赖关系。
|
||||
|
||||
#### 内存管理模块
|
||||
该库以内存管理模块为基础,通过两种内存管理结构,对于储存在内存中的数据进行组织、操作。该模块的子模块主要分为链式内存管理,块式内存管理。链式内存管理对于内存中离散的数据进行组织和管理;块式内存管理对于内存中的整块数据进行管理。这两个子模块会分别实现链式和块式的内存管理的管理结构及相关操作。该模块的第三个子模块是内存泄露管理模块,该模块对于已经分配的内存空间进行全面地监控,及时地完全地释放不需要的内存空间。内存泄漏管理对于长期运行的软件系统来说至关重要。链式和块式内存管理具体要实现的基本操作函数有:初始化类函数、赋值类函数、复制类函数、插入类函数、删除类函数、查询类函数、释放类函数。
|
||||
#### 内存管理模块(memory)
|
||||
该库以内存管理模块为基础,通过两种内存管理结构,对于储存在内存中的数据进行组织、操作。该模块的子模块主要分为链式内存管理(list),块式内存管理(block)。链式内存管理对于内存中离散的数据进行组织和管理;块式内存管理对于内存中的整块数据进行管理。这两个子模块会分别实现链式和块式的内存管理的管理结构及相关操作。该模块的第三个子模块是内存泄露管理模块,该模块对于已经分配的内存空间进行全面地监控,及时地完全地释放不需要的内存空间。内存泄漏管理对于长期运行的软件系统来说至关重要。链式和块式内存管理具体要实现的基本操作函数有:初始化类函数、赋值类函数、复制类函数、插入类函数、删除类函数、查询类函数、释放类函数。
|
||||
|
||||
#### 高级数据结构模块
|
||||
高级数据结构模块是对于内存管理模块的一次封装和抽象,它依赖于内存管理模块所提供的链式内存和块式内存管理结构和相关操作方法,运用相关方法来实现高级数据结构及其基本操作和算法。这些高级数据结构包括:目录树、二叉树、堆、栈、队列、有向图、无向图、链表、字典、字符串。通过高级数据模块,使得库能够更加快速地对于实际问题进行建模,更加有效率的解决实际问题。高级数据结构的子模块包含:基本操作子模块和算法子模块。前者完成了对于高级数据结构的基本操作:初始化数据结构、插入数据、删除数据、更新数据;后者将提供高级数据结构常用的高级算法:查找算法、排序算法、优化算法、转换算法。
|
||||
#### 高级数据结构模块(datastruct)
|
||||
高级数据结构模块是对于内存管理模块的一次封装和抽象,它依赖于内存管理模块所提供的链式内存和块式内存管理结构和相关操作方法,运用相关方法来实现高级数据结构及其基本操作和算法。这些高级数据结构包括:目录树(tree)、二叉树、堆、栈、队列、有向图、无向图、链表(chain)、字典、字符串。通过高级数据模块,使得库能够更加快速地对于实际问题进行建模,更加有效率的解决实际问题。高级数据结构的子模块包含:基本操作子模块和算法子模块。前者完成了对于高级数据结构的基本操作:初始化数据结构、插入数据、删除数据、更新数据;后者将提供高级数据结构常用的高级算法:查找算法、排序算法、优化算法、转换算法。
|
||||
|
||||
#### 文件储存模块
|
||||
文件储存模块依赖内存管理模块、回调机制模块和高级数据结构模块,该模块实现将内存数据管理结构与高级数据结构的信息及其中储存的数据储存到到文件中。该模块中定义的文件管理结构分为两类:关系型文件管理结构,非关系型文件管理结构。这两个结构的区别是是否记录所储存信息之间的关系。前者将有专门的数据结构来储存所储存的数据之间的联系,后者按照块的形式来叠放数据。模块内部将专门实现这两个数据管理结构写入文件、从文件读出的操作方法。并且,将实现各个高级数据结构与文件管理结构之间的转化。这样,能够直接将高级数据结构转化为文件管理结构,从而储存到文件中。或者,将文件中的数据读出,独处的数据在内存中的表现形式为对应的文件管理结构,而后再将文件管理结构转化为对应的高级数据结构。模块将实现对于这两种结构的操作方法:初始化,转化,写入,读取,释放。
|
||||
#### 文件储存模块(communicate_file)
|
||||
文件储存模块依赖内存管理模块、回调机制模块和高级数据结构模块,该模块实现将内存数据管理结构与高级数据结构的信息及其中储存的数据储存到到文件中。该模块中定义的文件管理结构分为两类:关系型文件管理结构(std),非关系型文件管理结构。这两个结构的区别是是否记录所储存信息之间的关系。前者将有专门的数据结构来储存所储存的数据之间的联系,后者按照块的形式来叠放数据。模块内部将专门实现这两个数据管理结构写入文件、从文件读出的操作方法。并且,将实现各个高级数据结构与文件管理结构之间的转化。这样,能够直接将高级数据结构转化为文件管理结构,从而储存到文件中。或者,将文件中的数据读出,独处的数据在内存中的表现形式为对应的文件管理结构,而后再将文件管理结构转化为对应的高级数据结构。模块将实现对于这两种结构的操作方法:初始化,转化,写入,读取,释放。
|
||||
|
||||
#### 网络传输模块
|
||||
网路传输模块依赖内存管理模块、回调机制模块、高级数据结构模块和文件储存模块,此模块主要提供将高级数据结构转化为文件信息管理结构,文件管理结构转化为网络信息块管理结构,将信息分块进行传输。对于简单的字符信息,该模块也提供网络消息管理结构,通过该结构能够在一台计算机和另外一台计算机之间传递字符串消息。模块将实现对于这两种结构的操作方法:初始化、转化、赋值、传输、释放。
|
||||
#### 网络传输模块(communicate_network)
|
||||
网路传输模块依赖内存管理模块、回调机制模块、高级数据结构模块和文件储存模块,此模块主要提供将高级数据结构转化为文件信息管理结构,文件管理结构转化为网络信息块管理结构,将信息分块进行传输。对于简单的字符信息,该模块也提供网络消息管理结构(message),通过该结构能够在一台计算机和另外一台计算机之间传递字符串消息。模块将实现对于这两种结构的操作方法:初始化、转化、赋值、传输、释放。
|
||||
|
||||
#### 回调机制模块
|
||||
#### 回调机制模块(event)
|
||||
回调机制模块依赖内存管理模块和高级数据结构,该模块实现一种方法调用机制,将实现回调函数的注册、传参、返回值传参的标准化宏与相关支撑函数。高级模块中的相关方法,通过使用以上的宏和函数,中能够以更加标准的、更加优雅的方法来实现相关功能。这也使得,事件机制的运用能够更加便捷有效,从而跨计算机之间的函数调用与传参成为可能。
|
||||
|
||||
#### 错误管理模块
|
||||
#### 错误管理模块(error)
|
||||
错误管理模块依赖内存管理模块和回调机制模块,该模块提供程序输出信息的分类:严重错误、错误、警告、提示。该模块将实现错误的处理函数的注册,在严重错误或者错误出现的情况下,根据开发者通过该模块的错误处理函数的注册信息,调用相应的错误处理函数并提供关键信息来辅助错误修复。该模块将提供相应的管理结构与方法来建立程序中的相关信息的日志文件,并且提供更加方便的方法来管理与更新相应的日志文件,实现程序输出信息的更加规范的清晰地产生与显示。
|
||||
|
||||
#### 子程序管理模块
|
||||
#### 子程序管理模块(subfunc)
|
||||
该模块依赖以上的所有模块,该模块也为该库的最高级的部分。该模块提供子程序的注册,调用,传输以及依赖关系的管理。子程序是一个独立的软件系统的所有功能的一部分,具有相对的独立性。一个程序的子程序可以储存在相同的计算机上,也可以储存在不同的计算机上,子程序之间不论储存的地方在何处,只要能够通过内存或者网络的方式访问到,则可以进行传参和调用。位置信息的记录与子程序的调用由相应的管理结构与操作方法来实现。对于一个要由多个子程序之间协调合作来完成的复杂任务的情景,该模块将通过子程序依赖关系管理结构及其方法来进行相应的系统性的有序调用。对于一个大任务中两个不互为依赖的过程,在允许的情况下模块将进行并行调用。通过子程序的传输方法,子程序能够更加方便地通过网络在计算机之间进行转移。总之,通过该模块,实现了一个独立的软件系统在不同的计算机中储存并且运行在不同计算机的内存中却可以虚拟出在同一计算机中储存运行的效果,能够并行执行软件系统中的某些功能,也可以让软件系统的设计者随时根据具体情况来转移子程序。
|
||||
|
||||
### 通信模块
|
||||
由于实际原因,网络传输模块与文件储存模块合为通信模块。
|
||||
### 通信模块(communicate)
|
||||
由于实际原因,网络传输模块与文件储存模块合为通信模块。通信模块统一负责内存管理结构、高级数据结构与文件和网络的对接工作。
|
||||
|
||||
### 目录结构管理方式
|
||||
- src:源文件
|
||||
@ -49,14 +49,14 @@
|
||||
- list 链式内存管理
|
||||
- tree 目录树
|
||||
- error:错误管理模块
|
||||
- subfunc:子程序管理模块
|
||||
- type.h:全局信息头文件
|
||||
- subfunc:子程序管理模块
|
||||
- type.h:全局信息头文件
|
||||
- document:文档
|
||||
- info:工程说明及计划文档
|
||||
- raw design:模块概要设计文档
|
||||
- design:模块详细设计文档
|
||||
- test:测试方案及数据文档
|
||||
- info:工程说明及计划文档
|
||||
- raw design:模块概要设计文档
|
||||
- design:模块详细设计文档
|
||||
- test:测试方案及数据文档
|
||||
- test:不同平台下的测试程序文件
|
||||
- unix
|
||||
- windows
|
||||
- unix
|
||||
- windows
|
||||
- bin:编译后的二进制文件
|
||||
|
147
ZE-Standard-Libraries.vcxproj
Normal file
147
ZE-Standard-Libraries.vcxproj
Normal file
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{77936A90-7A47-462C-BB65-1F4297AA853C}</ProjectGuid>
|
||||
<RootNamespace>ZEStandardLibraries</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="communicate\communicate.h" />
|
||||
<ClInclude Include="error\error.h" />
|
||||
<ClInclude Include="graph\graph.h" />
|
||||
<ClInclude Include="id\id.h" />
|
||||
<ClInclude Include="list\list.h" />
|
||||
<ClInclude Include="list\list_expand.h" />
|
||||
<ClInclude Include="stack\stack.h" />
|
||||
<ClInclude Include="stack\stack_expand.h" />
|
||||
<ClInclude Include="test.h" />
|
||||
<ClInclude Include="tree\tree.h" />
|
||||
<ClInclude Include="tree\tree_expand.h" />
|
||||
<ClInclude Include="type\type.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="communicate\communicate.c" />
|
||||
<ClCompile Include="error\error.c" />
|
||||
<ClCompile Include="graph\graph.c" />
|
||||
<ClCompile Include="id\id.c" />
|
||||
<ClCompile Include="list\list.c" />
|
||||
<ClCompile Include="list\list_expand.c" />
|
||||
<ClCompile Include="stack\stack.c" />
|
||||
<ClCompile Include="stack\stack_expand.c" />
|
||||
<ClCompile Include="test.c" />
|
||||
<ClCompile Include="tree\tree.c" />
|
||||
<ClCompile Include="tree\tree_expand.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
90
ZE-Standard-Libraries.vcxproj.filters
Normal file
90
ZE-Standard-Libraries.vcxproj.filters
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="communicate\communicate.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="error\error.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="graph\graph.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="id\id.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="list\list.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="list\list_expand.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stack\stack.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stack\stack_expand.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tree\tree.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tree\tree_expand.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="type\type.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="test.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="communicate\communicate.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="error\error.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="graph\graph.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="id\id.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="list\list.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="list\list_expand.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stack\stack.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stack\stack_expand.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tree\tree.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tree\tree_expand.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="test.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
4
ZE-Standard-Libraries.vcxproj.user
Normal file
4
ZE-Standard-Libraries.vcxproj.user
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
@ -232,7 +232,7 @@ extern void *getByPointerForNode(CNode *);
|
||||
/*
|
||||
*直接获得节点的序号
|
||||
*返回: 返回该节点在链表中的序号*/
|
||||
extern unsigned long long getIndexForNode(Chain *p_list,CNode *p_node);
|
||||
extern uint64_t getIndexForNode(Chain *p_list,CNode *p_node);
|
||||
|
||||
/*
|
||||
*通过节点的序号找到节点中相关的值,并更新其中的储存的值的指针.
|
||||
@ -262,7 +262,7 @@ Chain *copyList(Chain *p_list);
|
||||
/*
|
||||
*通过序号查找相关的单个节点
|
||||
*返回: 如果成功返回指向该节点的指针,如果失败则返回NULL.*/
|
||||
extern CNode *findByIndexForNode(Chain *, unsigned long long);
|
||||
extern CNode *findByIndexForNode(Chain *, uint64_t);
|
||||
|
||||
/*
|
||||
*通过整型值查找储存该值的单个节点
|
||||
@ -285,4 +285,149 @@ extern CNode *findByStringForNode(Chain *, char *);
|
||||
extern CNode *findByPointerForNode(Chain *, void *);
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*节点快速初始化相关宏,提供函数名较为简单的调用方式
|
||||
************************************************/
|
||||
|
||||
/****
|
||||
*不带ID模块相关宏
|
||||
*/
|
||||
|
||||
/*直接获取一个以整型值初始化的节点不带ID的缩略*/
|
||||
#define lni(cn) nodeWithInt(cn,0)
|
||||
|
||||
/*直接获取一个以无符号整型值初始化的不带ID节点的缩略*/
|
||||
#define lnu(cn) nodeWithUInt(cn,0)
|
||||
|
||||
/*直接获取一个以无符号长整形值初始化的节点的缩略*/
|
||||
#define lnull(cn) nodeWithULLInt(cn,0)
|
||||
|
||||
/*直接获取一个以浮点值初始化的不带ID节点的缩略*/
|
||||
#define lnd(cn) nodeWithDouble(cn,0)
|
||||
|
||||
/*直接获取一个以字符串值初始化的不带ID节点的缩略*/
|
||||
#define lns(cn) nodeWithString(cn,0)
|
||||
|
||||
/*直接获取一个以指针值初始化的不带ID节点的缩略*/
|
||||
#define lnp(cn) nodeWithPointer(cn,0)
|
||||
|
||||
/****
|
||||
*带ID模块的相关宏
|
||||
*/
|
||||
|
||||
/*直接获取一个以整型值初始化的带ID节点的缩略*/
|
||||
#define lsni(cn) nodeWithInt(cn,1)
|
||||
|
||||
/*直接获取一个以浮点值初始化的带ID节点的缩略*/
|
||||
#define lsnd(cn) nodeWithDouble(cn,1)
|
||||
|
||||
/*直接获取一个以字符串值初始化的带ID节点的缩略*/
|
||||
#define lsns(cn) nodeWithString(cn,1)
|
||||
|
||||
/*直接获取一个以指针值初始化的节点的缩略*/
|
||||
#define lsnp(cn) nodeWithPointer(cn,1)
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*链表快速插入相关宏
|
||||
************************************************/
|
||||
|
||||
/****
|
||||
*尾部相关
|
||||
*/
|
||||
|
||||
/*在链表尾部直接加入一个已经用整型值初始化的不带ID的节点*/
|
||||
#define lisrti(chain, cn) insertInTail(chain, lni(cn));
|
||||
|
||||
/*在链表尾部直接加入一个已经用浮点值初始化的不带ID的节点*/
|
||||
#define lisrtd(chain, cn) insertInTail(chain, lnd(cn));
|
||||
|
||||
/*在链表尾部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
|
||||
#define lisrtu(chain, cn) insertInTail(chain, lnu(cn));
|
||||
|
||||
/*在链表尾部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
|
||||
#define lisrtull(chain, cn) insertInTail(chain, lnull(cn));
|
||||
|
||||
/*在链表尾部直接加入一个已经用指针值初始化的不带ID的节点*/
|
||||
#define lisrtp(chain, cn) insertInTail(chain, lnp(cn));
|
||||
|
||||
/*在链表尾部直接加入一个已经用字符串值初始化的不带ID的节点*/
|
||||
#define lisrts(chain, cn) insertInTail(chain, lns(cn));
|
||||
|
||||
/****
|
||||
*头部相关
|
||||
*/
|
||||
|
||||
/*在链表头部直接加入一个已经用整型值初始化的不带ID的节点*/
|
||||
#define lisrhi(chain, cn) insertInHead(chain, lni(cn));
|
||||
|
||||
/*在链表头部直接加入一个已经用浮点值初始化的不带ID的节点*/
|
||||
#define lisrhd(chain, cn) insertInHead(chain, lnd(cn));
|
||||
|
||||
/*在链表头部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
|
||||
#define lisrhu(chain, cn) insertInHead(chain, lnu(cn));
|
||||
|
||||
/*在链表头部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
|
||||
#define lisrhull(chain, cn) insertInHead(chain, lnull(cn));
|
||||
|
||||
/*在链表头部直接加入一个已经用指针值初始化的不带ID的节点*/
|
||||
#define lisrhp(chain, cn) insertInHead(chain, lnp(cn));
|
||||
|
||||
/*在链表头部直接加入一个已经用字符串值初始化的不带ID的节点*/
|
||||
#define lisrhs(chain, cn) insertInHead(chain, lns(cn));
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*节点快速获得储存值相关宏
|
||||
************************************************/
|
||||
|
||||
/*快速获得指针类型的节点所储存的值*/
|
||||
#define lidxp(chain, cn) getByPointerForNode(findByIndexForNode(chain, cn))
|
||||
|
||||
/*快速获得整型类型的节点所储存的值*/
|
||||
#define lidxi(chain, cn) getByIntForNode(findByIndexForNode(chain, cn))
|
||||
|
||||
/*快速获得浮点类型的节点所储存的值*/
|
||||
#define lidxd(chain, cn) getByDoubleForNode(findByIndexForNode(chain, cn))
|
||||
|
||||
/*快速获得字符串类型的节点所储存的值*/
|
||||
#define lidxs(chain, cn) getByStringForNode(findByIndexForNode(chain, cn))
|
||||
|
||||
/*快速获得无符号长整型类型的节点所储存的值*/
|
||||
#define lupdull(chain,cn,value) updateValueWithULLIntForNode(findByIndexForNode(chain, cn),value)
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*其他快速操作相关宏
|
||||
************************************************/
|
||||
|
||||
/*通过节点的序号直接得到它的值*/
|
||||
#define lidxvle(chain,cn) (findByIndexForNode(chain, cn)->value)
|
||||
|
||||
/*通过节点序号直接移除节点*/
|
||||
#define lrmvidx(chain,cn) removeByNode(chain, findByIndexForNode(chain, cn)
|
||||
|
||||
/*从列表头移除节点的缩略*/
|
||||
#define lpoph(chain) popFromHead(chain)
|
||||
|
||||
/*从列表尾移除节点的缩略*/
|
||||
#define lpopt(chain) popFromTail(chain)
|
||||
|
||||
/*通过节点的ID直接获得节点的值*/
|
||||
#define lfndsid(chain,sid) (findByIdForNode(chain,sid)->value)
|
||||
|
||||
/*创建一个不带ID的链表的缩略*/
|
||||
#define lstns() initList(0);
|
||||
|
||||
/*创建一个带有ID的链表缩略*/
|
||||
#define lstn() initList(1);
|
||||
|
||||
#endif /* chain_h */
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef list_print_h
|
||||
#define list_print_h
|
||||
#ifndef chain_print_h
|
||||
#define chain_print_h
|
||||
|
||||
#include <chain/chain.h>
|
||||
#include <event/event.h>
|
||||
@ -39,4 +39,4 @@ __CALLBACK_STATE(printListForCustom);
|
||||
void printNode(CNode *p_node);
|
||||
|
||||
|
||||
#endif /* list_print_h */
|
||||
#endif /* chain_h */
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
#include <list/list_type.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
*节点的管理及操作的结构
|
||||
*/
|
||||
typedef struct Node CNode;
|
||||
|
||||
/*
|
||||
/**
|
||||
*链表的管理及操作的结构
|
||||
*/
|
||||
typedef struct List Chain;
|
||||
|
@ -102,8 +102,6 @@ extern int dataFileReadOut(D_FILE *p_dfile);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
相关结构的释放操作: 释放相关结构体所占内存空间的相关函数
|
||||
************************************************/
|
||||
|
@ -1,155 +1,8 @@
|
||||
#ifndef list_expand_1_h
|
||||
#define list_expand_1_h
|
||||
#ifndef event_h
|
||||
#define event_h
|
||||
|
||||
#include <chain/chain.h>
|
||||
|
||||
/************************************************
|
||||
*节点快速初始化相关宏,提供函数名较为简单的调用方式
|
||||
************************************************/
|
||||
|
||||
/****
|
||||
*不带ID模块相关宏
|
||||
*/
|
||||
|
||||
/*直接获取一个以整型值初始化的节点不带ID的缩略*/
|
||||
#define lni(x) nodeWithInt(x,0)
|
||||
|
||||
/*直接获取一个以无符号整型值初始化的不带ID节点的缩略*/
|
||||
#define lnu(x) nodeWithUInt(x,0)
|
||||
|
||||
/*直接获取一个以无符号长整形值初始化的节点的缩略*/
|
||||
#define lnull(x) nodeWithULLInt(x,0)
|
||||
|
||||
/*直接获取一个以浮点值初始化的不带ID节点的缩略*/
|
||||
#define lnd(x) nodeWithDouble(x,0)
|
||||
|
||||
/*直接获取一个以字符串值初始化的不带ID节点的缩略*/
|
||||
#define lns(x) nodeWithString(x,0)
|
||||
|
||||
/*直接获取一个以指针值初始化的不带ID节点的缩略*/
|
||||
#define lnp(x) nodeWithPointer(x,0)
|
||||
|
||||
/****
|
||||
*带ID模块的相关宏
|
||||
*/
|
||||
|
||||
/*直接获取一个以整型值初始化的带ID节点的缩略*/
|
||||
#define lsni(x) nodeWithInt(x,1)
|
||||
|
||||
/*直接获取一个以浮点值初始化的带ID节点的缩略*/
|
||||
#define lsnd(x) nodeWithDouble(x,1)
|
||||
|
||||
/*直接获取一个以字符串值初始化的带ID节点的缩略*/
|
||||
#define lsns(x) nodeWithString(x,1)
|
||||
|
||||
/*直接获取一个以指针值初始化的节点的缩略*/
|
||||
#define lsnp(x) nodeWithPointer(x,1)
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*链表快速插入相关宏
|
||||
************************************************/
|
||||
|
||||
/****
|
||||
*尾部相关
|
||||
*/
|
||||
|
||||
/*在链表尾部直接加入一个已经用整型值初始化的不带ID的节点*/
|
||||
#define lisrti(list, x) insertInTail(list, lni(x));
|
||||
|
||||
/*在链表尾部直接加入一个已经用浮点值初始化的不带ID的节点*/
|
||||
#define lisrtd(list, x) insertInTail(list, lnd(x));
|
||||
|
||||
/*在链表尾部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
|
||||
#define lisrtu(list, x) insertInTail(list, lnu(x));
|
||||
|
||||
/*在链表尾部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
|
||||
#define lisrtull(list, x) insertInTail(list, lnull(x));
|
||||
|
||||
/*在链表尾部直接加入一个已经用指针值初始化的不带ID的节点*/
|
||||
#define lisrtp(list, x) insertInTail(list, lnp(x));
|
||||
|
||||
/*在链表尾部直接加入一个已经用字符串值初始化的不带ID的节点*/
|
||||
#define lisrts(list, x) insertInTail(list, lns(x));
|
||||
|
||||
/****
|
||||
*头部相关
|
||||
*/
|
||||
|
||||
/*在链表头部直接加入一个已经用整型值初始化的不带ID的节点*/
|
||||
#define lisrhi(list, x) insertInHead(list, lni(x));
|
||||
|
||||
/*在链表头部直接加入一个已经用浮点值初始化的不带ID的节点*/
|
||||
#define lisrhd(list, x) insertInHead(list, lnd(x));
|
||||
|
||||
/*在链表头部直接加入一个已经用无符号整型值初始化的不带ID的节点*/
|
||||
#define lisrhu(list, x) insertInHead(list, lnu(x));
|
||||
|
||||
/*在链表头部直接加入一个已经用无符号长整型值初始化的不带ID的节点*/
|
||||
#define lisrhull(list, x) insertInHead(list, lnull(x));
|
||||
|
||||
/*在链表头部直接加入一个已经用指针值初始化的不带ID的节点*/
|
||||
#define lisrhp(list, x) insertInHead(list, lnp(x));
|
||||
|
||||
/*在链表头部直接加入一个已经用字符串值初始化的不带ID的节点*/
|
||||
#define lisrhs(list, x) insertInHead(list, lns(x));
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*节点快速获得储存值相关宏
|
||||
************************************************/
|
||||
|
||||
/*快速获得指针类型的节点所储存的值*/
|
||||
#define lidxp(list, x) getByPointerForNode(findByIndexForNode(list, x))
|
||||
|
||||
/*快速获得整型类型的节点所储存的值*/
|
||||
#define lidxi(list, x) getByIntForNode(findByIndexForNode(list, x))
|
||||
|
||||
/*快速获得浮点类型的节点所储存的值*/
|
||||
#define lidxd(list, x) getByDoubleForNode(findByIndexForNode(list, x))
|
||||
|
||||
/*快速获得字符串类型的节点所储存的值*/
|
||||
#define lidxs(list, x) getByStringForNode(findByIndexForNode(list, x))
|
||||
|
||||
/*快速获得无符号长整型类型的节点所储存的值*/
|
||||
#define lupdull(list,x,value) updateValueWithULLIntForNode(findByIndexForNode(list, x),value)
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*其他快速操作相关宏
|
||||
************************************************/
|
||||
|
||||
/*通过节点的序号直接得到它的值*/
|
||||
#define lidxvle(list,x) (findByIndexForNode(list, x)->value)
|
||||
|
||||
/*通过节点序号直接移除节点*/
|
||||
#define lrmvidx(list,x) removeByNode(list, findByIndexForNode(list, x)
|
||||
|
||||
/*从列表头移除节点的缩略*/
|
||||
#define lpoph(list) popFromHead(list)
|
||||
|
||||
/*从列表尾移除节点的缩略*/
|
||||
#define lpopt(list) popFromTail(list)
|
||||
|
||||
/*通过节点的ID直接获得节点的值*/
|
||||
#define lfndsid(list,sid) (findByIdForNode(list,sid)->value)
|
||||
|
||||
/*创建一个不带ID的链表的缩略*/
|
||||
#define lstns() initList(0);
|
||||
|
||||
/*创建一个带有ID的链表缩略*/
|
||||
#define lstn() initList(1);
|
||||
|
||||
#endif /* list_expand_1_h */
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
*回调函数的便捷操作相关宏
|
||||
************************************************/
|
||||
@ -226,3 +79,5 @@
|
||||
*若继续遍历则使用该宏
|
||||
*/
|
||||
#define __CRETURN__ newCReturn()
|
||||
|
||||
#endif /* event_h */
|
||||
|
@ -1,79 +0,0 @@
|
||||
#ifndef list_simple_h
|
||||
#define list_simple_h
|
||||
|
||||
#include <list/list_type.h>
|
||||
|
||||
|
||||
/************************************************
|
||||
*单向节点的快速初始化: 为新节点分配内存空间,
|
||||
* 并使用输入值对其进行初始化.
|
||||
************************************************/
|
||||
|
||||
/*
|
||||
*为新单向节点获取内存空间, 并使用整型值初始化新单向节点
|
||||
*返回: 若成功则返回指向新单向节点的指针,若失败函数返回NULL.*/
|
||||
extern s_Node *s_nodeWithInt(int);
|
||||
|
||||
/*
|
||||
*为新单向节点获取内存空间, 并使用无符号整型值初始化新单向节点
|
||||
*返回: 若成功则返回指向新单向节点的指针,若失败函数返回NULL.*/
|
||||
extern s_Node *s_nodeWithUInt(unsigned int);
|
||||
|
||||
/*
|
||||
*为新单向节点获取内存空间, 并使用浮点值初始化新单向节点
|
||||
*返回: 若成功则返回指向新单向节点的指针,若失败函数返回NULL.*/
|
||||
extern s_Node *s_nodeWithDouble(double);
|
||||
|
||||
/*
|
||||
*为新单向节点获取内存空间, 并使用字符串值初始化新单向节点
|
||||
*返回: 若成功则返回指向新单向节点的指针,若失败函数返回NULL.*/
|
||||
extern s_Node *s_nodeWithString(const char *);
|
||||
|
||||
/*
|
||||
*为新单向节点获取内存空间, 并使用指针值初始化新单向节点
|
||||
*返回: 若成功则返回指向新单向节点的指针,若失败函数返回NULL.*/
|
||||
extern s_Node *s_nodeWithPointer(const void *);
|
||||
|
||||
|
||||
/*
|
||||
*初始化单向链表节点,该种类节点可以与普通储存在List结构中.
|
||||
*单向链表的引入主要在于对于简单问题提供更小开销的解决方案.但相应的操作函数较少,不如一般链表方便.
|
||||
*返回: 如果成功返回指向该节点的指针,如果失败则返回NULL.*/
|
||||
extern s_Node *s_initNode(void);
|
||||
|
||||
/*在单项链表的头部插入一个节点
|
||||
*返回: 若成功函数返回0,若失败函数返回-1.*/
|
||||
extern int s_insertInHead(List *p_list, s_Node *s_p_node);
|
||||
|
||||
/*
|
||||
*在单项链表的尾部插入一个节点
|
||||
*返回: 若成功函数返回0,若失败函数返回-1.*/
|
||||
extern int s_insertInTail(List *p_list, s_Node *s_p_node);
|
||||
|
||||
/*
|
||||
*释放单向节点所占的内存空间
|
||||
*返回: 如果成功返回0, 失败则返回-1.*/
|
||||
extern int s_releaseNode(s_Node *s_p_node);
|
||||
|
||||
/*
|
||||
*释放单向链表所占的内存空间
|
||||
*返回: 如果成功返回0, 失败则返回-1.*/
|
||||
extern int s_releaseList(List *p_list);
|
||||
|
||||
/*
|
||||
*自定义释放单向链表所占的内存空间
|
||||
*参数: func是一个函数指针,它指向的函数现在每次释放节点时调用,
|
||||
* 接收储存在节点中的值的指针,释放用户自定义的结构体的所占用内存.
|
||||
* 回调函数返回0代表释放成功,返回-1代表释放失败.
|
||||
*返回: 如果成功返回0, 失败则返回-1.*/
|
||||
extern int s_releaseListForCustom(List *p_list, int (*func)(void *));
|
||||
|
||||
/*
|
||||
*自定义释放单向节点所占的内存空间
|
||||
*参数: func是一个函数指针,它指向的函数现在每次释放单项节点时调用,
|
||||
* 接收储存在单项节点中的值得指针,释放用户自定义的结构体的所占用内存.
|
||||
* 回调函数返回0代表释放成功,返回-1代表释放失败.
|
||||
*返回: 如果成功返回0, 失败则返回-1.*/
|
||||
extern int s_releaseNodeForCustom(s_Node *s_p_node, int (*func)(void *));
|
||||
|
||||
#endif /* list_simple_h */
|
@ -6,24 +6,24 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
*节点的管理及操作的结构
|
||||
*链式结构节点的管理及操作的结构
|
||||
*/
|
||||
typedef struct Node{
|
||||
unsigned int type;//类型
|
||||
void *value;//值指针
|
||||
struct Node *next;//指向下一个节点
|
||||
struct Node *last;//指向上一个节点
|
||||
struct Node *next;//指向下一个链式结构节点
|
||||
struct Node *last;//指向上一个链式结构节点
|
||||
#ifdef id_enable
|
||||
SID *s_id;
|
||||
#endif
|
||||
} Node;
|
||||
|
||||
/*
|
||||
*链表的管理及操作的结构
|
||||
*链式结构的管理及操作的结构
|
||||
*/
|
||||
typedef struct List{
|
||||
Node *head;//指向第一个节点
|
||||
Node *tail;//指向最后一个节点
|
||||
Node *head;//指向第一个链式结构节点
|
||||
Node *tail;//指向最后一个链式结构节点
|
||||
uint64_t length;
|
||||
#ifdef id_enable
|
||||
SID *s_id;
|
||||
|
@ -33,7 +33,6 @@
|
||||
#define STRING 3
|
||||
#define POINTER 4
|
||||
#define LIST 5
|
||||
#define STACK 6
|
||||
#define TREE 7
|
||||
#define LIST_NODE 8
|
||||
#define TREE_NODE 9
|
||||
@ -43,7 +42,6 @@
|
||||
#define STANDARD_DATA 13
|
||||
#define DATA_FILE 14
|
||||
#define MESSAGE 15
|
||||
#define HOLE 16
|
||||
#define ULLINT 17
|
||||
|
||||
|
||||
@ -69,10 +67,6 @@
|
||||
#define FILE_TSET_LEN 18
|
||||
#define HEAD_TEST_LEN 9
|
||||
#define INFO_TEST_LEN 8
|
||||
#define ENABLE_LIST_QUICK 65535
|
||||
#define FN_NODE_SPARE 500
|
||||
#define INDEX_CHANGE_MAX 500
|
||||
#define INDEX_DISTANCE_MAX 120
|
||||
#define STD_TEXT_LEN 4
|
||||
#define HIGH 0x3
|
||||
#define STANDARD 0x2
|
||||
|
@ -9,7 +9,7 @@
|
||||
@return 以字节为单位返回链表及链表内包含的节点所占的内存空间
|
||||
*/
|
||||
uint64_t calListMemory(Chain * p_list){
|
||||
Node *p_node = p_list->head;
|
||||
CNode *p_node = p_list->head;
|
||||
uint64_t nodes_size = 0LL;
|
||||
uint64_t list_size = sizeof(p_list);
|
||||
while(p_node != NULL){
|
||||
|
@ -187,7 +187,7 @@ inline Chain *mply_findByPointerForNode(Chain* p_list, void *temp) {
|
||||
@param m_index 序号位置
|
||||
@return 返回指向符合条件的链表的指针
|
||||
*/
|
||||
CNode *findByIndexForNode(Chain *p_list, unsigned long long m_index) {
|
||||
CNode *findByIndexForNode(Chain *p_list, uint64_t m_index) {
|
||||
if(p_list == NULL) return NULL;
|
||||
CNode *p_node = p_list->head;
|
||||
unsigned long long i;
|
||||
|
@ -21,7 +21,7 @@ int getByIntForNode(CNode *p_node) {
|
||||
@return 成功则返回对应无符号整型值,失败返回0
|
||||
*/
|
||||
unsigned int getByUIntForNode(CNode *p_node){
|
||||
if (p_node->type == UINT) return *(unsigned int *)(p_node->value);
|
||||
if (p_node->type == UINT) return *(uint32_t *)(p_node->value);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ void *getByPointerForNode(CNode *p_node) {
|
||||
@param p_node 指向目标节点的指针
|
||||
@return 成功返回相应排列序号,失败则会返回0
|
||||
*/
|
||||
unsigned long long getIndexByNode(Chain *p_list, CNode *p_node) {
|
||||
uint64_t getIndexByNode(Chain *p_list, CNode *p_node) {
|
||||
register CNode *t_node = p_list->head;
|
||||
register unsigned long long index = 0;
|
||||
register uint64_t index = 0;
|
||||
while (t_node != NULL) {
|
||||
// id模块可能启用的时候则编译以下代码
|
||||
#ifdef id_enable
|
||||
@ -78,3 +78,15 @@ unsigned long long getIndexByNode(Chain *p_list, CNode *p_node) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
通过链表中相应的节点获得其在链表中的排列序号
|
||||
|
||||
@param p_list 指向目标链表
|
||||
@param p_node 指向目标节点的指针
|
||||
@return 成功返回相应排列序号,失败则会返回0
|
||||
*/
|
||||
extern uint64_t getIndexForNode(Chain *p_list,CNode *p_node){
|
||||
return getIndexByNode(p_list, p_node);
|
||||
|
||||
}
|
||||
|
@ -105,13 +105,9 @@ Chain *newReturn(int if_status ,int status, char *argc, ...){
|
||||
lisrtull(p_list, va_arg(args, unsigned long long));
|
||||
count += 2;
|
||||
}
|
||||
else{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
lisrtu(p_list, va_arg(args, unsigned int));
|
||||
else count++;
|
||||
}
|
||||
else lisrtu(p_list, va_arg(args, unsigned int));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -130,6 +126,6 @@ Chain *newReturn(int if_status ,int status, char *argc, ...){
|
||||
|
||||
@return 指向构造的参数列表的指针
|
||||
*/
|
||||
Chain *newCReturn(void){
|
||||
inline Chain *newCReturn(void){
|
||||
return newReturn(1, 0, NULL);
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
|
||||
/**
|
||||
以一个已存在的节点为模板创建一个相同的新的节点
|
||||
以一个已存在的链式结构节点为模板创建一个相同的新的链式结构节点
|
||||
|
||||
@param p_node 指向作为模板的节点的指针
|
||||
@return 返回指向新的节点的指针
|
||||
@param p_node 指向作为模板的链式结构节点的指针
|
||||
@return 返回指向新的链式结构节点的指针
|
||||
*/
|
||||
Node *copyNode(Node *p_node) {
|
||||
Node *t_node = NULL;
|
||||
@ -25,10 +25,10 @@ Node *copyNode(Node *p_node) {
|
||||
|
||||
|
||||
/**
|
||||
根据已存在的链表创建一个相同的新的链表
|
||||
根据已存在的链式结构创建一个相同的新的链式结构
|
||||
|
||||
@param p_list 指向作为模板的链表的指针
|
||||
@return 返回指向新链表的指针
|
||||
@param p_list 指向作为模板的链式结构的指针
|
||||
@return 返回指向新链式结构的指针
|
||||
*/
|
||||
List *copyList(List *p_list) {
|
||||
Node *p_node;
|
||||
|
@ -4,11 +4,11 @@
|
||||
//如果ID模块可能启用则编译以下代码
|
||||
#ifdef id_enable
|
||||
/**
|
||||
通过ID查找链表中符合条件的第一个节点
|
||||
通过ID查找链式结构中符合条件的第一个链式结构节点
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@param s_id ID值
|
||||
@return 成功返回指向符合条件的节点的指针,不成功则返回NULL
|
||||
@return 成功返回指向符合条件的链式结构节点的指针,不成功则返回NULL
|
||||
*/
|
||||
Node *findByIdForNode(List *p_list, SID * s_id) {
|
||||
Node *ph_node = p_list->head;
|
||||
@ -39,12 +39,12 @@ Node *findByIdForNode(List *p_list, SID * s_id) {
|
||||
|
||||
|
||||
/**
|
||||
通过值来查找链表中符合条件的第一个节点
|
||||
通过值来查找链式结构中符合条件的第一个链式结构节点
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@param type 值的类型
|
||||
@param value 值
|
||||
@return 成功返回指向符合条件的节点的指针,不成功则返回NULL
|
||||
@return 成功返回指向符合条件的链式结构节点的指针,不成功则返回NULL
|
||||
*/
|
||||
Node *findByValue(List *p_list, uint type, const void *value) {
|
||||
Node *p_node = p_list->head;
|
||||
@ -82,12 +82,12 @@ Node *findByValue(List *p_list, uint type, const void *value) {
|
||||
}
|
||||
|
||||
/**
|
||||
通过值来查找链表中符合条件的所有节点
|
||||
通过值来查找链式结构中符合条件的所有链式结构节点
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@param type 值的类型
|
||||
@param value 值
|
||||
@return 返回含有所有符合条件的节点的重组链表
|
||||
@return 返回含有所有符合条件的链式结构节点的重组链式结构
|
||||
*/
|
||||
List *mply_findByValue(List *p_list, unsigned int type, const void *value) {
|
||||
List *f_list = initList(0);
|
||||
|
@ -3,20 +3,20 @@
|
||||
|
||||
|
||||
/**
|
||||
返回链表的长度
|
||||
返回链式结构的长度
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@return 返回目标链表的长度
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@return 返回目标链式结构的长度
|
||||
*/
|
||||
uint64_t len(List *p_list) {
|
||||
return p_list->length;
|
||||
}
|
||||
|
||||
/**
|
||||
检查链表是否为空
|
||||
检查链式结构是否为空
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@return 目标链表为空返回1,不为空返回0
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@return 目标链式结构为空返回1,不为空返回0
|
||||
*/
|
||||
int isListEmpty(List *p_list) {
|
||||
if (p_list->head == NULL || p_list->tail == NULL)// If its head or tail is NULL,it would be thought as empty.
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
|
||||
/**
|
||||
创建一个新的节点,并为其分配内存空间
|
||||
创建一个新的链式结构节点,并为其分配内存空间
|
||||
|
||||
@param if_sid 新的节点是否带ID
|
||||
@return 返回指向新的节点的内存地址指针
|
||||
@param if_sid 新的链式结构节点是否带ID
|
||||
@return 返回指向新的链式结构节点的内存地址指针
|
||||
*/
|
||||
#ifdef id_enable
|
||||
Node *initNode(_Bool if_sid)
|
||||
@ -27,7 +27,7 @@ Node *initNode(void)
|
||||
p_node->next = NULL;
|
||||
p_node->last = NULL;
|
||||
p_node->type = VOID;
|
||||
// 链表内存安全模式相关操作
|
||||
// 链式结构内存安全模式相关操作
|
||||
if (if_safeModeForNode) {
|
||||
if_safeModeForNode = 0;
|
||||
prec_node = initNode(0);
|
||||
@ -39,10 +39,10 @@ Node *initNode(void)
|
||||
}
|
||||
|
||||
/**
|
||||
创建一个新的链表,并为其分配内存空间
|
||||
创建一个新的链式结构,并为其分配内存空间
|
||||
|
||||
@param if_sid 新的链表是否带ID
|
||||
@return 返回指向新的链表的内存地址指针
|
||||
@param if_sid 新的链式结构是否带ID
|
||||
@return 返回指向新的链式结构的内存地址指针
|
||||
*/
|
||||
#ifdef id_enable
|
||||
List *initList(_Bool if_sid)
|
||||
@ -73,9 +73,9 @@ List *initList(void)
|
||||
}
|
||||
|
||||
/**
|
||||
为新的节点设定初始值
|
||||
为新的链式结构节点设定初始值
|
||||
|
||||
@param p_node 指向目标节点的指针
|
||||
@param p_node 指向目标链式结构节点的指针
|
||||
@param type 值得类型
|
||||
@param p_value 指向目标值的内存空间的指针
|
||||
@return 执行成功则返回0
|
||||
|
@ -2,10 +2,10 @@
|
||||
#include <list/list.h>
|
||||
|
||||
/**
|
||||
在链表的头部插入节点
|
||||
在链式结构的头部插入链式结构节点
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@param p_node 指向目标节点的指针
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@param p_node 指向目标链式结构节点的指针
|
||||
@return 函数执行成功返回0
|
||||
*/
|
||||
int insertInHead(List *p_list, Node *p_node) {
|
||||
@ -24,19 +24,13 @@ int insertInHead(List *p_list, Node *p_node) {
|
||||
}
|
||||
|
||||
/**
|
||||
在链表的尾部插入节点
|
||||
在链式结构的尾部插入链式结构节点
|
||||
|
||||
@param p_list 指向目标链表的指针
|
||||
@param p_node 指向目标节点的指针
|
||||
@param p_list 指向目标链式结构的指针
|
||||
@param p_node 指向目标链式结构节点的指针
|
||||
@return 函数执行成功返回0
|
||||
*/
|
||||
int insertInTail(List *p_list, Node *p_node) {
|
||||
// 如果可能需要使用长链表模块则编译以下代码
|
||||
/*
|
||||
#ifdef list_quick_enable
|
||||
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
|
||||
#endif
|
||||
*/
|
||||
if (isListEmpty(p_list)) {
|
||||
p_list->head = p_node;
|
||||
p_list->tail = p_node;
|
||||
|
@ -6,7 +6,7 @@ int releaseNode(Node *p_node) {
|
||||
removeByNode(node_list, p_node);
|
||||
}
|
||||
if (p_node->value != NULL) {
|
||||
if (p_node->type != POINTER && p_node->type != HOLE) {
|
||||
if (p_node->type != POINTER) {
|
||||
if (p_node->type == LIST) {
|
||||
releaseList((List *)p_node->value);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <type.h>
|
||||
#include <list/list.h>
|
||||
#include <chain/chain_quick.h>
|
||||
|
||||
static int if_safeModeForNode = 0;
|
||||
static List *node_list = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user