-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export module design_skiplist.Skiplist;
- Loading branch information
Showing
9 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Xmake cache | ||
.xmake/ | ||
build/ | ||
|
||
# MacOS Cache | ||
.DS_Store | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# this is the build file for project | ||
# it is autogenerated by the xmake build system. | ||
# do not edit by hand. | ||
|
||
# project | ||
cmake_minimum_required(VERSION 3.15.0) | ||
cmake_policy(SET CMP0091 NEW) | ||
project(design-skiplist LANGUAGES CXX C) | ||
|
||
# target | ||
add_library(design-skiplist STATIC "") | ||
set_target_properties(design-skiplist PROPERTIES OUTPUT_NAME "design-skiplist") | ||
set_target_properties(design-skiplist PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/windows/x86/release") | ||
add_custom_command(OUTPUT output_design-skiplist_D4E52589 | ||
COMMAND echo [ 0%]: compiling.module.release design_skiplist.Skiplist | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/design-skiplist/windows/x86/release | ||
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX86/x86/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/index.ixx -Fo${CMAKE_SOURCE_DIR}/build/.objs/design-skiplist/windows/x86/release/index.ixx.obj -ifcOutput ${CMAKE_SOURCE_DIR}/build/.gens/design-skiplist/windows/x86/release/rules/modules/cache/57cc73b0/design_skiplist.Skiplist.ifc -interface | ||
VERBATIM | ||
) | ||
add_custom_target(target_design-skiplist_D4E52589 | ||
DEPENDS output_design-skiplist_D4E52589 | ||
) | ||
add_dependencies(design-skiplist target_design-skiplist_D4E52589) | ||
target_compile_options(design-skiplist PRIVATE | ||
$<$<COMPILE_LANGUAGE:C>:-DNDEBUG> | ||
$<$<COMPILE_LANGUAGE:CXX>:-DNDEBUG> | ||
$<$<COMPILE_LANGUAGE:CXX>:-experimental:module> | ||
) | ||
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") | ||
target_compile_options(design-skiplist PRIVATE /EHsc) | ||
else() | ||
target_compile_options(design-skiplist PRIVATE -fcxx-exceptions) | ||
endif() | ||
set_target_properties(design-skiplist PROPERTIES CXX_EXTENSIONS OFF) | ||
target_compile_features(design-skiplist PRIVATE cxx_std_20) | ||
if(MSVC) | ||
target_compile_options(design-skiplist PRIVATE $<$<CONFIG:Release>:-Ox -fp:fast>) | ||
else() | ||
target_compile_options(design-skiplist PRIVATE -O3) | ||
endif() | ||
if(MSVC) | ||
else() | ||
target_compile_options(design-skiplist PRIVATE -fvisibility=hidden) | ||
endif() | ||
if(MSVC) | ||
set_property(TARGET design-skiplist PROPERTY | ||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
endif() | ||
target_link_libraries(design-skiplist PRIVATE | ||
${CMAKE_SOURCE_DIR}/build/.objs/design-skiplist/windows/x86/release/index.ixx.obj | ||
) | ||
target_sources(design-skiplist PRIVATE index.ixx | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.33530.505 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "design-skiplist", "design-skiplist.vcxproj", "{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Debug|x64.ActiveCfg = Debug|x64 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Debug|x64.Build.0 = Debug|x64 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Debug|x86.Build.0 = Debug|Win32 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Release|x64.ActiveCfg = Release|x64 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Release|x64.Build.0 = Release|x64 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Release|x86.ActiveCfg = Release|Win32 | ||
{DB9746EA-85D1-4222-83B2-FD9F8C0233B5}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F99AF492-BC2E-48FB-86A7-2FDDBFF988F7} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" 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> | ||
<ItemGroup> | ||
<ClCompile Include="index.ixx" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{db9746ea-85d1-4222-83b2-fd9f8c0233b5}</ProjectGuid> | ||
<RootNamespace>designskiplist</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.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>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</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" /> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<LanguageStandard>stdcpp20</LanguageStandard> | ||
<LanguageStandard_C>stdc17</LanguageStandard_C> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="头文件"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;h++;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> | ||
<ClCompile Include="index.ixx"> | ||
<Filter>源文件</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"style": "WebKit", | ||
"filter": [ | ||
"*.c", | ||
"*.cc", | ||
"*.cpp", | ||
"*.h", | ||
"*.hh", | ||
"*.ixx", | ||
"*.hpp" | ||
], | ||
"dirs": [ | ||
"./" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module; | ||
#include <unordered_map> | ||
export module design_skiplist.Skiplist; | ||
using std::unordered_map; | ||
|
||
namespace design_skiplist { | ||
export class Skiplist { | ||
private: | ||
unordered_map<int, int> storage; | ||
|
||
public: | ||
Skiplist() | ||
= default; | ||
|
||
bool search(int target) | ||
{ | ||
return (storage.count(target) ? storage.at(target) : 0) > 0; | ||
} | ||
|
||
void add(int num) | ||
{ | ||
storage[num]++; | ||
} | ||
|
||
bool erase(int num) | ||
{ | ||
if ((storage.count(num) ? storage.at(num) : 0) == 1) { | ||
storage.erase(num); | ||
return true; | ||
} | ||
if (search(num)) { | ||
storage[num]--; | ||
|
||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
add_rules("mode.debug", "mode.release") | ||
set_languages("c17", "cxx20") | ||
target("design-skiplist") | ||
set_kind("static") | ||
add_files("index.ixx") | ||
|
||
|
||
-- | ||
-- If you want to known more usage about xmake, please see https://xmake.io | ||
-- | ||
-- ## FAQ | ||
-- | ||
-- You can enter the project directory firstly before building project. | ||
-- | ||
-- $ cd projectdir | ||
-- | ||
-- 1. How to build project? | ||
-- | ||
-- $ xmake | ||
-- | ||
-- 2. How to configure project? | ||
-- | ||
-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] | ||
-- | ||
-- 3. Where is the build output directory? | ||
-- | ||
-- The default output directory is `./build` and you can configure the output directory. | ||
-- | ||
-- $ xmake f -o outputdir | ||
-- $ xmake | ||
-- | ||
-- 4. How to run and debug target after building project? | ||
-- | ||
-- $ xmake run [targetname] | ||
-- $ xmake run -d [targetname] | ||
-- | ||
-- 5. How to install target to the system directory or other output directory? | ||
-- | ||
-- $ xmake install | ||
-- $ xmake install -o installdir | ||
-- | ||
-- 6. Add some frequently-used compilation flags in xmake.lua | ||
-- | ||
-- @code | ||
-- -- add debug and release modes | ||
-- add_rules("mode.debug", "mode.release") | ||
-- | ||
-- -- add macro defination | ||
-- add_defines("NDEBUG", "_GNU_SOURCE=1") | ||
-- | ||
-- -- set warning all as error | ||
-- set_warnings("all", "error") | ||
-- | ||
-- -- set language: c99, c++11 | ||
-- set_languages("c99", "c++11") | ||
-- | ||
-- -- set optimization: none, faster, fastest, smallest | ||
-- set_optimize("fastest") | ||
-- | ||
-- -- add include search directories | ||
-- add_includedirs("/usr/include", "/usr/local/include") | ||
-- | ||
-- -- add link libraries and search directories | ||
-- add_links("tbox") | ||
-- add_linkdirs("/usr/local/lib", "/usr/lib") | ||
-- | ||
-- -- add system link libraries | ||
-- add_syslinks("z", "pthread") | ||
-- | ||
-- -- add compilation and link flags | ||
-- add_cxflags("-stdnolib", "-fno-strict-aliasing") | ||
-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) | ||
-- | ||
-- @endcode | ||
-- | ||
|