diff options
Diffstat (limited to 'src/boost/libs/icl/example/dynamic_interval_')
4 files changed, 476 insertions, 0 deletions
diff --git a/src/boost/libs/icl/example/dynamic_interval_/dynamic_interval.cpp b/src/boost/libs/icl/example/dynamic_interval_/dynamic_interval.cpp new file mode 100644 index 00000000..8cdb34c1 --- /dev/null +++ b/src/boost/libs/icl/example/dynamic_interval_/dynamic_interval.cpp @@ -0,0 +1,140 @@ +/*-----------------------------------------------------------------------------+ +Interval Container Library +Author: Joachim Faulhaber +Copyright (c) 2007-2010: Joachim Faulhaber +Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin ++------------------------------------------------------------------------------+ + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENCE.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) ++-----------------------------------------------------------------------------*/ +/** Example dynamic_interval.cpp \file dynamic_interval.cpp + \brief Intervals with dynamic interval bounds that can be changed at runtime. + + Intervals types with dynamic interval bounds can represent closed and + open interval borders. Interval borders are not static or fixed for + the type but may change due to computations in interval containers. + Dynamically bounded intervals are the library default for interval + parameters in interval containers. + + \include dynamic_interval_/dynamic_interval.cpp +*/ +//[example_dynamic_interval +#include <iostream> +#include <string> +#include <math.h> +#include <boost/type_traits/is_same.hpp> + +#include <boost/icl/interval_set.hpp> +#include <boost/icl/split_interval_set.hpp> +// Dynamically bounded intervals 'discrete_interval' and 'continuous_interval' +// are indirectly included via interval containers as library defaults. +#include "../toytime.hpp" +#include <boost/icl/rational.hpp> + +using namespace std; +using namespace boost; +using namespace boost::icl; + +int main() +{ + cout << ">>Interval Container Library: Sample interval.cpp <<\n"; + cout << "----------------------------------------------------\n"; + + // Dynamically bounded intervals are the library default for + // interval parameters in interval containers. + BOOST_STATIC_ASSERT(( + boost::is_same< interval_set<int>::interval_type + , discrete_interval<int> >::value + )); + + + BOOST_STATIC_ASSERT(( + boost::is_same< interval_set<float>::interval_type + , continuous_interval<float> >::value + )); + + // As we can see the library default chooses the appropriate + // class template instance discrete_interval<T> or continuous_interval<T> + // dependent on the domain_type T. The library default for intervals + // is also available via the template 'interval': + BOOST_STATIC_ASSERT(( + boost::is_same< interval<int>::type + , discrete_interval<int> >::value + )); + + BOOST_STATIC_ASSERT(( + boost::is_same< interval<float>::type + , continuous_interval<float> >::value + )); + + // template interval also provides static functions for the four border types + + interval<int>::type int_interval = interval<int>::closed(3, 7); + interval<double>::type sqrt_interval = interval<double>::right_open(1/sqrt(2.0), sqrt(2.0)); + interval<string>::type city_interval = interval<string>::left_open("Barcelona", "Boston"); + interval<Time>::type time_interval = interval<Time>::open(Time(monday,8,30), Time(monday,17,20)); + + cout << "----- Dynamically bounded intervals ----------------------------------------\n"; + cout << " discrete_interval<int> : " << int_interval << endl; + cout << "continuous_interval<double>: " << sqrt_interval << " does " + << string(contains(sqrt_interval, sqrt(2.0))?"":"NOT") + << " contain sqrt(2)" << endl; + cout << "continuous_interval<string>: " << city_interval << " does " + << string(contains(city_interval,"Barcelona")?"":"NOT") + << " contain 'Barcelona'" << endl; + cout << "continuous_interval<string>: " << city_interval << " does " + << string(contains(city_interval, "Berlin")?"":"NOT") + << " contain 'Berlin'" << endl; + cout << " discrete_interval<Time> : " << time_interval << "\n\n"; + + // Using dynamically bounded intervals allows to apply operations + // with intervals and also with elements on all interval containers + // including interval containers of continuous domain types: + + interval<rational<int> >::type unit_interval + = interval<rational<int> >::right_open(rational<int>(0), rational<int>(1)); + interval_set<rational<int> > unit_set(unit_interval); + interval_set<rational<int> > ratio_set(unit_set); + ratio_set -= rational<int>(1,3); // Subtract 1/3 from the set + + cout << "----- Manipulation of single values in continuous sets ---------------------\n"; + cout << "1/3 subtracted from [0..1) : " << ratio_set << endl; + cout << "The set does " << string(contains(ratio_set, rational<int>(1,3))?"":"NOT") + << " contain '1/3'" << endl; + ratio_set ^= unit_set; + cout << "Flipping the holey set : " << ratio_set << endl; + cout << "yields the subtracted : 1/3\n\n"; + + // Of course we can use interval types that are different from the + // library default by explicit instantiation: + split_interval_set<int, std::less, closed_interval<Time> > intuitive_times; + // Interval set 'intuitive_times' uses statically bounded closed intervals + intuitive_times += closed_interval<Time>(Time(monday, 9,00), Time(monday, 10,59)); + intuitive_times += closed_interval<Time>(Time(monday, 10,00), Time(monday, 11,59)); + cout << "----- Here we are NOT using the library default for intervals --------------\n"; + cout << intuitive_times << endl; + + return 0; +} + +// Program output: +//>>Interval Container Library: Sample interval.cpp << +//---------------------------------------------------- +//----- Dynamically bounded intervals ---------------------------------------- +// discrete_interval<int> : [3,7] +//continuous_interval<double>: [0.707107,1.41421) does NOT contain sqrt(2) +//continuous_interval<string>: (Barcelona,Boston] does NOT contain 'Barcelona' +//continuous_interval<string>: (Barcelona,Boston] does contain 'Berlin' +// discrete_interval<Time> : (mon:08:30,mon:17:20) +// +//----- Manipulation of single values in continuous sets --------------------- +//1/3 subtracted from [0..1) : {[0/1,1/3)(1/3,1/1)} +//The set does NOT contain '1/3' +//Flipping the holey set : {[1/3,1/3]} +//yields the subtracted : 1/3 +// +//----- Here we are NOT using the library default for intervals -------------- +//{[mon:09:00,mon:09:59][mon:10:00,mon:10:59][mon:11:00,mon:11:59]} +//] + diff --git a/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj b/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj new file mode 100644 index 00000000..a7aeb73a --- /dev/null +++ b/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.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> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{EE61B7EF-EC45-4165-8B59-FD5B7D3A9F7C}</ProjectGuid> + <RootNamespace>Dynamic_interval</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../bin/debug/\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../../../bin/obj/$(ProjectName)/debug/\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../bin/release/\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../../bin/obj/$(ProjectName)/release/\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <Link> + <OutputFile>../../../../bin/debug/$(ProjectName).exe</OutputFile> + <AdditionalLibraryDirectories>../../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalIncludeDirectories>../../../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <OutputFile>../../../../bin/release/$(ProjectName).exe</OutputFile> + <AdditionalLibraryDirectories>../../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="dynamic_interval.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\..\..\boost\itl\dynamic_interval.hpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj.filters b/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj.filters new file mode 100644 index 00000000..baf45cf3 --- /dev/null +++ b/src/boost/libs/icl/example/dynamic_interval_/vc10_dynamic_interval.vcxproj.filters @@ -0,0 +1,27 @@ +<?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;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;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</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="dynamic_interval.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\..\..\boost\itl\dynamic_interval.hpp"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/icl/example/dynamic_interval_/vc9_dynamic_interval.vcproj b/src/boost/libs/icl/example/dynamic_interval_/vc9_dynamic_interval.vcproj new file mode 100644 index 00000000..126807a8 --- /dev/null +++ b/src/boost/libs/icl/example/dynamic_interval_/vc9_dynamic_interval.vcproj @@ -0,0 +1,206 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="vc9_dynamic_interval" + ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D3A9F7C}" + RootNamespace="Dynamic_interval" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="../../../../bin/debug/" + IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../../" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../../bin/debug/$(ProjectName).exe" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../../lib" + GenerateDebugInformation="true" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="../../../../bin/release/" + IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../../" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../../bin/release/$(ProjectName).exe" + LinkIncremental="1" + AdditionalLibraryDirectories="../../../../lib" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dynamic_interval.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath="..\..\..\..\boost\itl\dynamic_interval.hpp" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |