mirror of
https://github.com/boostorg/container.git
synced 2025-08-03 14:34:27 +02:00
Add custom random_shuffle as some old compiler implementations self-swap some elements.
This commit is contained in:
@@ -37,6 +37,19 @@ void compare_times(cpu_times time_numerator, cpu_times time_denominator){
|
|||||||
std::cout << "----------------------------------------------" << '\n' << std::endl;
|
std::cout << "----------------------------------------------" << '\n' << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< class RandomIt >
|
||||||
|
void random_shuffle( RandomIt first, RandomIt last )
|
||||||
|
{
|
||||||
|
typedef typename boost::container::iterator_traits<RandomIt>::difference_type difference_type;
|
||||||
|
difference_type n = last - first;
|
||||||
|
for (difference_type i = n-1; i > 0; --i) {
|
||||||
|
difference_type j = std::rand() % (i+1);
|
||||||
|
if(j != i) {
|
||||||
|
boost::adl_move_swap(first[i], first[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boost::container::vector<int> sorted_unique_range_int;
|
boost::container::vector<int> sorted_unique_range_int;
|
||||||
boost::container::vector<int> sorted_range_int;
|
boost::container::vector<int> sorted_range_int;
|
||||||
boost::container::vector<int> random_unique_range_int;
|
boost::container::vector<int> random_unique_range_int;
|
||||||
@@ -57,11 +70,11 @@ void fill_range_ints()
|
|||||||
//random_range_int
|
//random_range_int
|
||||||
std::srand(0);
|
std::srand(0);
|
||||||
random_range_int.assign(sorted_range_int.begin(), sorted_range_int.end());
|
random_range_int.assign(sorted_range_int.begin(), sorted_range_int.end());
|
||||||
std::random_shuffle(random_range_int.begin(), random_range_int.end());
|
::random_shuffle(random_range_int.begin(), random_range_int.end());
|
||||||
//random_unique_range_int
|
//random_unique_range_int
|
||||||
std::srand(0);
|
std::srand(0);
|
||||||
random_unique_range_int.assign(sorted_unique_range_int.begin(), sorted_unique_range_int.end());
|
random_unique_range_int.assign(sorted_unique_range_int.begin(), sorted_unique_range_int.end());
|
||||||
std::random_shuffle(random_unique_range_int.begin(), random_unique_range_int.end());
|
::random_shuffle(random_unique_range_int.begin(), random_unique_range_int.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::container::vector<boost::container::string> sorted_unique_range_string;
|
boost::container::vector<boost::container::string> sorted_unique_range_string;
|
||||||
@@ -93,11 +106,11 @@ void fill_range_strings()
|
|||||||
//random_range_string
|
//random_range_string
|
||||||
std::srand(0);
|
std::srand(0);
|
||||||
random_range_string.assign(sorted_range_string.begin(), sorted_range_string.end());
|
random_range_string.assign(sorted_range_string.begin(), sorted_range_string.end());
|
||||||
std::random_shuffle(random_range_string.begin(), random_range_string.end());
|
::random_shuffle(random_range_string.begin(), random_range_string.end());
|
||||||
//random_unique_range_string
|
//random_unique_range_string
|
||||||
std::srand(0);
|
std::srand(0);
|
||||||
random_unique_range_string.assign(sorted_unique_range_string.begin(), sorted_unique_range_string.end());
|
random_unique_range_string.assign(sorted_unique_range_string.begin(), sorted_unique_range_string.end());
|
||||||
std::random_shuffle(random_unique_range_string.begin(), random_unique_range_string.end());
|
::random_shuffle(random_unique_range_string.begin(), random_unique_range_string.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@@ -1,136 +1,135 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="bench_set"
|
Name="bench_set"
|
||||||
ProjectGUID="{5E1C1C23-26A9-4FE5-A24E-DA735271C32B}"
|
ProjectGUID="{5E1C1C23-26A9-4FE5-A24E-DA735271C32B}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="../../Bin/Win32/Debug"
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
IntermediateDirectory="Debug/bench_set"
|
IntermediateDirectory="Debug/bench_set"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../../.."
|
AdditionalIncludeDirectories="../../../.."
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
ExceptionHandling="TRUE"
|
ExceptionHandling="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="FALSE"
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="3"/>
|
DebugInformationFormat="3"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="winmm.lib"
|
AdditionalDependencies="winmm.lib libboost_chrono-vc71-mt-gd-1_61.lib libboost_timer-vc71-mt-gd-1_61.lib libboost_system-vc71-mt-gd-1_61.lib"
|
||||||
OutputFile="$(OutDir)/bench_set_d.exe"
|
OutputFile="$(OutDir)/bench_set_d.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile="$(OutDir)/bench_set.pdb"
|
ProgramDatabaseFile="$(OutDir)/bench_set.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
FixedBaseAddress="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="../../Bin/Win32/Release"
|
|
||||||
IntermediateDirectory="Release/bench_set"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../../../.."
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
|
||||||
ForceConformanceInForLoopScope="FALSE"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="4"
|
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
|
||||||
DebugInformationFormat="0"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="winmm.lib"
|
|
||||||
OutputFile="$(OutDir)/bench_set.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
SubSystem="1"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
FixedBaseAddress="1"/>
|
FixedBaseAddress="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
<Configuration
|
||||||
<References>
|
Name="Release|Win32"
|
||||||
</References>
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
<Files>
|
IntermediateDirectory="Release/bench_set"
|
||||||
<Filter
|
ConfigurationType="1"
|
||||||
Name="Source Files"
|
CharacterSet="2">
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
<Tool
|
||||||
UniqueIdentifier="{4B737ACF-06A6-1243-CC8A-3D7D42A02A3F}">
|
Name="VCCLCompilerTool"
|
||||||
<File
|
AdditionalIncludeDirectories="../../../.."
|
||||||
RelativePath="..\..\bench\bench_set.cpp">
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
</File>
|
RuntimeLibrary="2"
|
||||||
</Filter>
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
</Files>
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
<Globals>
|
UsePrecompiledHeader="0"
|
||||||
</Globals>
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/bench_set.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4B737ACF-06A6-1243-CC8A-3D7D42A02A3F}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\bench\bench_set.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
Reference in New Issue
Block a user