Compare commits

..

27 Commits

Author SHA1 Message Date
4c72b78551 merged from trunk
[SVN r49607]
2008-11-06 00:15:47 +00:00
6702b04019 merged from trunk
[SVN r48605]
2008-09-05 04:13:30 +00:00
4e17ef2b40 merged from trunk
[SVN r47983]
2008-08-05 05:39:57 +00:00
f62e23a14c merged from trunk
[SVN r45985]
2008-05-31 19:31:01 +00:00
8ff3ace362 merged from trunk
[SVN r45289]
2008-05-11 18:27:27 +00:00
a232c948bf post-review proto version
[SVN r44061]
2008-04-05 18:00:00 +00:00
a389d768c4 Fix broken copyright urls. Fixes #1573.
[SVN r43422]
2008-02-27 18:51:14 +00:00
90fca39906 Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
5b24f31486 merging changes from 1.34
[SVN r40698]
2007-11-02 21:00:08 +00:00
b25d6511b3 merging changes from 1.34
[SVN r40697]
2007-11-02 20:55:26 +00:00
1541a554f5 changed range_result_iterator to range_iterator
[SVN r40518]
2007-10-27 22:52:29 +00:00
7a97b3390e Added missing include.
[SVN r39586]
2007-09-28 07:19:29 +00:00
6e5a7497ae Added missing include.
[SVN r39519]
2007-09-25 08:46:31 +00:00
f0b8b60379 Update
[SVN r38522]
2007-08-08 19:24:04 +00:00
66019abb2f Update
[SVN r38521]
2007-08-08 19:23:38 +00:00
8758222006 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
4eef56761a find/split iterator tests added
[SVN r38126]
2007-07-01 22:24:29 +00:00
b94a3fbfba adapting to new range interface
[SVN r38125]
2007-07-01 22:23:55 +00:00
614cc2ebab adapting to new range interface
[SVN r38123]
2007-07-01 13:29:56 +00:00
869660ed14 adapted to the new range interface
[SVN r38122]
2007-07-01 13:12:57 +00:00
777f30780e Fix broken build of docs, it was missing a dependency to the doxygen docs.
[SVN r37466]
2007-04-17 17:19:25 +00:00
26aa37733b Fix a few more references to *.boosbook instead of *.xml generated files.
[SVN r37465]
2007-04-17 17:13:35 +00:00
f1e60579c2 documentation typo fixed
[SVN r36843]
2007-01-30 07:59:28 +00:00
389dd3c863 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
f23f61ae9b License added to the xml doc files
[SVN r34895]
2006-08-16 07:17:49 +00:00
608112b112 boost guidelines (mainly from inspect tool: tabs, license reference text, etc.)
[SVN r34752]
2006-07-27 10:27:37 +00:00
b21b54dc4e Applying patch from Nicola Musatti
[SVN r33709]
2006-04-16 09:46:34 +00:00
7 changed files with 140 additions and 33 deletions

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
#----------------------------------------------------------------------------
# This file was automatically generated from the original CMakeLists.txt file
# Add a variable to hold the headers for the library
set (lib_headers
algorithm
)
# Add a library target to the build system
boost_library_project(
algorithm
# SRCDIRS
TESTDIRS minmax/test string/test
HEADERS ${lib_headers}
# DOCDIRS
DESCRIPTION "A library of various algorithms."
MODULARIZED
AUTHORS "Pavol Droba <droba -at- topmail.sk>"
"Herve Bronnimann <hbr -at- poly.edu>"
# MAINTAINERS
)

View File

@ -28,11 +28,7 @@ namespace boost {
// classification functors -----------------------------------------------//
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif
// is_classified functor
// is_classified functor
struct is_classifiedF :
public predicate_facade<is_classifiedF>
{
@ -42,7 +38,6 @@ namespace boost {
// Constructor from a locale
is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
m_Type(Type), m_Locale(Loc) {}
// Operation
template<typename CharT>
bool operator()( CharT Ch ) const
@ -59,13 +54,10 @@ namespace boost {
#endif
private:
const std::ctype_base::mask m_Type;
const std::locale m_Locale;
std::ctype_base::mask m_Type;
std::locale m_Locale;
};
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
// is_any_of functor
/*
@ -77,9 +69,7 @@ namespace boost {
{
private:
// set cannot operate on const value-type
typedef typename remove_const<CharT>::type set_value_type;
// Size of the static storage (size of pointer*2)
static const ::std::size_t FIXED_STORAGE_SIZE = sizeof(set_value_type*)*2;
typedef typename ::boost::remove_const<CharT>::type set_value_type;
public:
// Boost.Lambda support
@ -96,7 +86,7 @@ namespace boost {
m_Size=Size;
set_value_type* Storage=0;
if(m_Size<=FIXED_STORAGE_SIZE)
if(use_fixed_storage(m_Size))
{
// Use fixed storage
Storage=&m_Storage.m_fixSet[0];
@ -121,7 +111,7 @@ namespace boost {
const set_value_type* SrcStorage=0;
set_value_type* DestStorage=0;
if(m_Size<=FIXED_STORAGE_SIZE)
if(use_fixed_storage(m_Size))
{
// Use fixed storage
DestStorage=&m_Storage.m_fixSet[0];
@ -142,36 +132,80 @@ namespace boost {
// Destructor
~is_any_ofF()
{
if(m_Size>FIXED_STORAGE_SIZE && m_Storage.m_dynSet!=0)
if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
{
delete m_Storage.m_dynSet;
delete [] m_Storage.m_dynSet;
}
}
// Assignment
is_any_ofF& operator=(const is_any_ofF& Other)
{
// Prepare storage
m_Storage.m_dynSet=0;
m_Size=Other.m_Size;
const set_value_type* SrcStorage=0;
set_value_type* DestStorage=0;
// Handle self assignment
if(this==&Other) return *this;
if(m_Size<=FIXED_STORAGE_SIZE)
// Prepare storage
const set_value_type* SrcStorage;
set_value_type* DestStorage;
if(use_fixed_storage(Other.m_Size))
{
// Use fixed storage
DestStorage=&m_Storage.m_fixSet[0];
SrcStorage=&Other.m_Storage.m_fixSet[0];
// Delete old storage if was present
if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
{
delete [] m_Storage.m_dynSet;
}
// Set new size
m_Size=Other.m_Size;
}
else
{
// Use dynamic storage
m_Storage.m_dynSet=new set_value_type[m_Size];
DestStorage=m_Storage.m_dynSet;
// Other uses dynamic storage
SrcStorage=Other.m_Storage.m_dynSet;
// Check what kind of storage are we using right now
if(use_fixed_storage(m_Size))
{
// Using fixed storage, allocate new
set_value_type* pTemp=new set_value_type[Other.m_Size];
DestStorage=pTemp;
m_Storage.m_dynSet=pTemp;
m_Size=Other.m_Size;
}
else
{
// Using dynamic storage, check if can reuse
if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size<Other.m_Size*2)
{
// Reuse the current storage
DestStorage=m_Storage.m_dynSet;
m_Size=Other.m_Size;
}
else
{
// Allocate the new one
set_value_type* pTemp=new set_value_type[Other.m_Size];
DestStorage=pTemp;
// Delete old storage if necessary
if(m_Storage.m_dynSet!=0)
{
delete [] m_Storage.m_dynSet;
}
// Store the new storage
m_Storage.m_dynSet=pTemp;
// Set new size
m_Size=Other.m_Size;
}
}
}
// Use fixed storage
// Copy the data
::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
return *this;
@ -182,12 +216,19 @@ namespace boost {
bool operator()( Char2T Ch ) const
{
const set_value_type* Storage=
(m_Size<=FIXED_STORAGE_SIZE)
(use_fixed_storage(m_Size))
? &m_Storage.m_fixSet[0]
: m_Storage.m_dynSet;
return ::std::binary_search(Storage, Storage+m_Size, Ch);
}
private:
// check if the size is eligible for fixed storage
static bool use_fixed_storage(std::size_t size)
{
return size<=sizeof(set_value_type*)*2;
}
private:
// storage
@ -195,7 +236,7 @@ namespace boost {
union
{
set_value_type* m_dynSet;
set_value_type m_fixSet[FIXED_STORAGE_SIZE];
set_value_type m_fixSet[sizeof(set_value_type*)*2];
}
m_Storage;

View File

@ -56,7 +56,7 @@ be enough. The present library solves both problems.</p>
<tt>minmax</tt>
as straightforward extensions of the C++
standard. As it returns a pair of <tt>const&amp;</tt>, we must use the <a
href=:../../../../tuple/index.html>Boost.tuple</a> library to construct such
href="../../tuple/index.html">Boost.tuple</a> library to construct such
pairs. (Please note: the intent is not to fix the known defaults of
<tt>std::min</tt>
and <tt>std::max</tt>, but to add one more algorithms that combines both; see the

View File

@ -0,0 +1,8 @@
#-------------------------------------------------------------------------
#-- Needed include directories for the tests
boost_test_add_dependent_includes("utility;detail;config;test;mpl;bind;type_traits;static_assert;preprocessor;array;iterator;timer;tuple;range")
#-------------------------------------------------------------------------
boost_test_run(minmax_element_test)
boost_test_run(minmax_test)

1
module.cmake Normal file
View File

@ -0,0 +1 @@
boost_module(algorithm DEPENDS regex concept_check)

View File

@ -0,0 +1,16 @@
#-------------------------------------------------------------------------
#-- Needed include directories for the tests
boost_test_add_dependent_includes("utility;detail;config;test;mpl;bind;type_traits;static_assert;preprocessor;array;iterator;exception;range;timer")
#-------------------------------------------------------------------------
boost_test_run(trim_test)
boost_test_run(conv_test)
boost_test_run(predicate_test)
boost_test_run(find_test)
boost_test_run(split_test)
boost_test_run(join_test)
boost_test_run(replace_test)
boost_test_run(regex_test DEPENDS boost_regex SHARED)

View File

@ -96,10 +96,29 @@ void predicate_test()
}
template<typename Pred, typename Input>
void test_pred(const Pred& pred, const Input& input, bool bYes)
{
// test assignment operator
Pred pred1=pred;
pred1=pred;
pred1=pred1;
if(bYes)
{
BOOST_CHECK( all( input, pred ) );
BOOST_CHECK( all( input, pred1 ) );
}
else
{
BOOST_CHECK( !all( input, pred ) );
BOOST_CHECK( !all( input, pred1 ) );
}
}
#define TEST_CLASS( Pred, YesInput, NoInput )\
{\
BOOST_CHECK( all( string(YesInput), Pred ) );\
BOOST_CHECK( !all( string(NoInput), Pred ) );\
test_pred(Pred, YesInput, true); \
test_pred(Pred, NoInput, false); \
}
void classification_test()