feat: std::vector DeDuplication
This commit is contained in:
41
DeDuplication/DeDuplication.sln
Normal file
41
DeDuplication/DeDuplication.sln
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32802.440
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeDuplication", "DeDuplication\DeDuplication.vcxproj", "{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Unique", "Unique\Unique.vcxproj", "{E65BD110-0E5A-44EE-B304-314596C38A9F}"
|
||||
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
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Debug|x64.Build.0 = Debug|x64
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Release|x64.ActiveCfg = Release|x64
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Release|x64.Build.0 = Release|x64
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{5FAA2373-0F7C-4CD9-BA01-564733CAF15C}.Release|x86.Build.0 = Release|Win32
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Debug|x64.Build.0 = Debug|x64
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Release|x64.ActiveCfg = Release|x64
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Release|x64.Build.0 = Release|x64
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E65BD110-0E5A-44EE-B304-314596C38A9F}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {95AA5051-90E8-4FA2-8BC0-4437FF90275A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
1
DeDuplication/DeDuplication/DeDuplication.cpp
Normal file
1
DeDuplication/DeDuplication/DeDuplication.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "DeDuplication.h"
|
54
DeDuplication/DeDuplication/DeDuplication.h
Normal file
54
DeDuplication/DeDuplication/DeDuplication.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
using namespace std;
|
||||
|
||||
struct MyData
|
||||
{
|
||||
wstring name;
|
||||
wstring md5;
|
||||
};
|
||||
|
||||
class DeDuplication
|
||||
{
|
||||
private:
|
||||
static bool cmpSort(const MyData& d1, const MyData& d2) { // ע<>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD>̬
|
||||
// Simple example
|
||||
return d1.md5 < d2.md5;
|
||||
|
||||
// Complex sample
|
||||
//if (d1.md5 != d2.md5)
|
||||
// return d1.md5 < d2.md5;
|
||||
//else
|
||||
// return d1.name < d2.name;
|
||||
};
|
||||
|
||||
public:
|
||||
void finally()
|
||||
{
|
||||
wcout.imbue(locale("", LC_CTYPE));
|
||||
wcout << L"----------<2D><><EFBFBD><EFBFBD>ǰ--------" << endl;
|
||||
for (const auto& it : m_vec)
|
||||
wcout << L"[it.name]" << it.name << L"[it.md5]" << it.md5 << endl;
|
||||
|
||||
|
||||
set<MyData, decltype(DeDuplication::cmpSort)*> s(&DeDuplication::cmpSort);
|
||||
for (unsigned i = 0; i < m_vec.size(); ++i)
|
||||
s.insert(m_vec[i]);
|
||||
|
||||
m_vec.assign(s.begin(), s.end());
|
||||
|
||||
wcout << L"----------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------" << endl;
|
||||
for (const auto& it : m_vec)
|
||||
wcout << L"[it.name]" << it.name << L"[it.md5]" << it.md5 << endl;
|
||||
};
|
||||
|
||||
private:
|
||||
vector<MyData> m_vec = { { L"a1.exe", L"B9204B6362A65C248950D5A41F341DCC"},
|
||||
{ L"a2.exe", L"B9204B6362A65C248950D5A41F341DCC"},
|
||||
{ L"b1.exe", L"C96D1AA5D314954417C28A645ED72665"},
|
||||
{ L"b2.exe", L"C96D1AA5D314954417C28A645ED72665"} };
|
||||
};
|
151
DeDuplication/DeDuplication/DeDuplication.vcxproj
Normal file
151
DeDuplication/DeDuplication/DeDuplication.vcxproj
Normal file
@@ -0,0 +1,151 @@
|
||||
<?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>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{5faa2373-0f7c-4cd9-ba01-564733caf15c}</ProjectGuid>
|
||||
<RootNamespace>DeDuplication</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>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</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" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
</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>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DeDuplication.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DeDuplication.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
30
DeDuplication/DeDuplication/DeDuplication.vcxproj.filters
Normal file
30
DeDuplication/DeDuplication/DeDuplication.vcxproj.filters
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<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="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<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="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DeDuplication.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DeDuplication.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
13
DeDuplication/DeDuplication/main.cpp
Normal file
13
DeDuplication/DeDuplication/main.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// DeDuplication.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "DeDuplication.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
DeDuplication deDup;
|
||||
deDup.finally();
|
||||
|
||||
return 0;
|
||||
}
|
92
DeDuplication/Unique/Unique.cpp
Normal file
92
DeDuplication/Unique/Unique.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
// Unique.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
using namespace std;
|
||||
|
||||
/* <20><>Ӧ<EFBFBD>̳<EFBFBD>
|
||||
* STL <20>и<EFBFBD> vector ȥ<>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>: https://xmuli.blog.csdn.net/article/details/126322011
|
||||
* STL <20><> std::set <20><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><F3A3ACB6><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ıȽϺ<C8BD><CFBA><EFBFBD>: https://xmuli.blog.csdn.net/article/details/126354597
|
||||
*/
|
||||
|
||||
struct MyData
|
||||
{
|
||||
wstring name;
|
||||
wstring md5;
|
||||
|
||||
// <20><>ʽһ<CABD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> < <20><><EFBFBD><EFBFBD>
|
||||
//bool operator<(const MyData& d) const noexcept {
|
||||
// return md5 < d.md5;
|
||||
//}
|
||||
};
|
||||
|
||||
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ȽϺ<C8BD><CFBA><EFBFBD> _Pr <20><><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>õķ<C3B5>ʽ<EFBFBD><CABD>
|
||||
bool cmpSort(const MyData& d1, const MyData& d2) {
|
||||
// Simple example
|
||||
return d1.md5 < d2.md5;
|
||||
|
||||
// Complex sample
|
||||
//if (d1.md5 != d2.md5)
|
||||
// return d1.md5 < d2.md5;
|
||||
//else
|
||||
// return d1.name < d2.name;
|
||||
};
|
||||
|
||||
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lambda <20><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD>л<EFBFBD>ʧЧ<CAA7><D0A7>
|
||||
auto cmpSortLambda = [](const MyData& d1, const MyData& d2) {
|
||||
return d1.md5 < d2.md5;
|
||||
};
|
||||
|
||||
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>Եģ<D4B5><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>
|
||||
struct cmpSortObj
|
||||
{
|
||||
bool operator()(const MyData& d1, const MyData& d2) const {
|
||||
return d1.md5 < d2.md5;
|
||||
}
|
||||
};
|
||||
|
||||
// ************* std::unique <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ȽϺ<C8BD><CFBA><EFBFBD> *************
|
||||
bool cmpUnique(const MyData& d1, const MyData& d2) {
|
||||
return d1.md5 == d2.md5; // <20><><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD>ԴﵽĿ<EFB5BD>꣬<EFBFBD><EAA3AC><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
|
||||
//return d1.md5 == d2.md5 && d1.name == d2.name; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<MyData> vec = { { L"a1.exe", L"B9204B6362A65C248950D5A41F341DCC"},
|
||||
{ L"a2.exe", L"B9204B6362A65C248950D5A41F341DCC"},
|
||||
{ L"b1.exe", L"C96D1AA5D314954417C28A645ED72665"},
|
||||
{ L"b2.exe", L"C96D1AA5D314954417C28A645ED72665"} };
|
||||
|
||||
wcout.imbue(locale("", LC_CTYPE));
|
||||
wcout << L"----------<2D><><EFBFBD><EFBFBD>ǰ--------" << endl;
|
||||
for (const auto& it : vec)
|
||||
wcout << L"[it.name]" << it.name << L"[it.md5]" << it.md5 << endl;
|
||||
|
||||
// ************* <20><>һ<EFBFBD><D2BB>vector, sort + unique *************
|
||||
//sort(vec.begin(), vec.end(), cmpSort);
|
||||
//auto ite = std::unique(vec.begin(), vec.end(), cmpUnique);
|
||||
//vec.erase(ite, vec.end());
|
||||
|
||||
// ************* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vector + set<65><74><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֵ<EFBFBD><D6B5> *************
|
||||
//set<MyData, cmpSortObj> s; // "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><><EFBFBD><EFBFBD> set <20><><EFBFBD><EFBFBD> --> OK
|
||||
set<MyData, decltype(cmpSort)*> s(&cmpSort); // "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD> + decltype"<22><><EFBFBD><EFBFBD> set <20><><EFBFBD><EFBFBD> --> OK: <20><><EFBFBD>롢<EFBFBD><EBA1A2><EFBFBD>гɹ<D0B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>ɹ<EFBFBD>
|
||||
//set<MyData, decltype(cmpSort)*> s; // --> Error: <20><><EFBFBD>롢<EFBFBD><EBA1A2><EFBFBD>гɹ<D0B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
|
||||
for (unsigned i = 0; i < vec.size(); ++i)
|
||||
s.insert(vec[i]); // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>֤<EFBFBD><D6A4><EFBFBD>洴<EFBFBD><E6B4B4> std::set <20>Ľ<EFBFBD><C4BD><EFBFBD>
|
||||
vec.assign(s.begin(), s.end());
|
||||
|
||||
// ************* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vector + set<65><74><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD> *************
|
||||
// Ч<>ʲ<EFBFBD><CAB2>硺<EFBFBD><E7A1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
wcout << L"----------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------" << endl;
|
||||
for (const auto& it : vec)
|
||||
wcout << L"[it.name]" << it.name << L"[it.md5]" << it.md5 << endl;
|
||||
|
||||
return 0;
|
||||
}
|
148
DeDuplication/Unique/Unique.vcxproj
Normal file
148
DeDuplication/Unique/Unique.vcxproj
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{e65bd110-0e5a-44ee-b304-314596c38a9f}</ProjectGuid>
|
||||
<RootNamespace>Unique</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>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</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" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</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>
|
||||
</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>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Unique.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
DeDuplication/Unique/Unique.vcxproj.filters
Normal file
22
DeDuplication/Unique/Unique.vcxproj.filters
Normal file
@@ -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="Source Files">
|
||||
<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="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<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="Unique.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user