Skip to content

Commit dd9f13d

Browse files
committed
HtmlParser
1 parent 97c74da commit dd9f13d

File tree

8 files changed

+219
-10
lines changed

8 files changed

+219
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,4 +2590,6 @@ https://leetcode.cn/problems/zigzag-iterator/
25902590

25912591
https://leetcode.cn/problems/traffic-light-controlled-intersection/
25922592

2593+
https://leetcode.cn/problems/web-crawler-multithreaded/
2594+
25932595
</details>

split-a-circular-linked-list/test.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,28 @@ using namespace leetcode_test::split_a_circular_linked_list;
1717
using namespace std;
1818
using std::vector;
1919
template <class T>
20-
concept sizable = requires(T& t)
21-
{
20+
concept sizable = requires(T& t) {
2221
{
2322
t.size()
24-
} -> std::same_as<size_t>;
23+
} -> std::same_as<size_t>;
2524
};
2625
template <class T>
27-
concept iterable = requires(T& t)
28-
{
26+
concept iterable = requires(T& t) {
2927
++t.begin();
3028
{
3129
t.begin() != t.end()
3230

33-
} -> std::same_as<bool>;
31+
} -> std::same_as<bool>;
3432
};
3533

3634
template <class T, typename Y>
37-
concept equalable = requires(T& t, Y& y, size_t i)
38-
{
35+
concept equalable = requires(T& t, Y& y, size_t i) {
3936
{
4037
*t.begin() == *y.begin()
41-
} -> std::same_as<bool>;
38+
} -> std::same_as<bool>;
4239
};
4340
template <typename T, typename Y>
44-
requires sizable<T> and sizable<Y> and equalable<T, Y> and iterable<T> and iterable<Y>
41+
requires sizable<T> and sizable<Y> and equalable<T, Y> and iterable<T> and iterable<Y>
4542
auto assertContentEquals(T& left, Y& right)
4643
{
4744

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module;
2+
#include <chrono>
3+
#include <string>
4+
#include <thread>
5+
#include <vector>
6+
export module leetcode_test.web_crawler_multithreaded.HtmlParser;
7+
using std::string;
8+
using std::vector;
9+
namespace leetcode_test::web_crawler_multithreaded {
10+
export class HtmlParser {
11+
12+
public:
13+
vector<string> getUrls(string url)
14+
{
15+
using namespace std::chrono_literals;
16+
std::this_thread::sleep_for(15ms);
17+
}
18+
19+
HtmlParser(vector<string>& urls, vector<vector<int>>& edges) { }
20+
};
21+
22+
} // namespace leetcode_test::web_crawler_multithreaded

web-crawler-multithreaded/index.ixx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module;
2+
#include <string>
3+
#include <vector>
4+
export module leetcode_test.web_crawler_multithreaded.Solution;
5+
import leetcode_test.web_crawler_multithreaded.HtmlParser;
6+
using std::string;
7+
using std::vector;
8+
namespace leetcode_test::web_crawler_multithreaded {
9+
10+
export class Solution {
11+
public:
12+
vector<string> crawl(string startUrl, HtmlParser htmlParser) { }
13+
14+
private:
15+
static string getHostname(const string& url)
16+
{
17+
const int firstSlash = url.find_first_of('/');
18+
const int thirdSlash = url.find_first_of('/', firstSlash + 2);
19+
return url.substr(firstSlash + 2, thirdSlash - firstSlash - 2);
20+
}
21+
};
22+
23+
} // namespace leetcode_test::web_crawler_multithreaded
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33627.172
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "web-crawler-multithreaded", "web-crawler-multithreaded.vcxproj", "{8101F835-716F-45A1-BC0E-40658E4D105E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Debug|x64.ActiveCfg = Debug|x64
17+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Debug|x64.Build.0 = Debug|x64
18+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Debug|x86.ActiveCfg = Debug|Win32
19+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Debug|x86.Build.0 = Debug|Win32
20+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Release|x64.ActiveCfg = Release|x64
21+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Release|x64.Build.0 = Release|x64
22+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Release|x86.ActiveCfg = Release|Win32
23+
{8101F835-716F-45A1-BC0E-40658E4D105E}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {12557B56-5789-48A3-8430-4D7A768EAA9D}
30+
EndGlobalSection
31+
EndGlobal
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>17.0</VCProjectVersion>
23+
<ProjectGuid>{8101F835-716F-45A1-BC0E-40658E4D105E}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v143</PlatformToolset>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34+
<ConfigurationType>Application</ConfigurationType>
35+
<UseDebugLibraries>false</UseDebugLibraries>
36+
<PlatformToolset>v143</PlatformToolset>
37+
</PropertyGroup>
38+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
39+
<ConfigurationType>Application</ConfigurationType>
40+
<UseDebugLibraries>true</UseDebugLibraries>
41+
<PlatformToolset>v143</PlatformToolset>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
44+
<ConfigurationType>Application</ConfigurationType>
45+
<UseDebugLibraries>false</UseDebugLibraries>
46+
<PlatformToolset>v143</PlatformToolset>
47+
</PropertyGroup>
48+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
49+
<ImportGroup Label="ExtensionSettings">
50+
</ImportGroup>
51+
<ImportGroup Label="Shared">
52+
</ImportGroup>
53+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
54+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
55+
</ImportGroup>
56+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
57+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<PropertyGroup Label="UserMacros" />
66+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
67+
<LinkIncremental>true</LinkIncremental>
68+
</PropertyGroup>
69+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
70+
<LinkIncremental>true</LinkIncremental>
71+
</PropertyGroup>
72+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<ClCompile>
74+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
75+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
76+
<WarningLevel>Level3</WarningLevel>
77+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
78+
<Optimization>Disabled</Optimization>
79+
</ClCompile>
80+
<Link>
81+
<TargetMachine>MachineX86</TargetMachine>
82+
<GenerateDebugInformation>true</GenerateDebugInformation>
83+
<SubSystem>Console</SubSystem>
84+
</Link>
85+
</ItemDefinitionGroup>
86+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
87+
<ClCompile>
88+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
90+
<WarningLevel>Level3</WarningLevel>
91+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
92+
</ClCompile>
93+
<Link>
94+
<TargetMachine>MachineX86</TargetMachine>
95+
<GenerateDebugInformation>true</GenerateDebugInformation>
96+
<SubSystem>Console</SubSystem>
97+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
98+
<OptimizeReferences>true</OptimizeReferences>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
102+
<ClCompile>
103+
<LanguageStandard>stdcpp20</LanguageStandard>
104+
</ClCompile>
105+
</ItemDefinitionGroup>
106+
<ItemGroup>
107+
<ClCompile Include="HtmlParser.ixx" />
108+
<ClCompile Include="index.ixx" />
109+
</ItemGroup>
110+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
111+
<ImportGroup Label="ExtensionTargets">
112+
</ImportGroup>
113+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

0 commit comments

Comments
 (0)