aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-11 10:08:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-11 10:08:28 +0000
commit8fe0374c9bb9f452bced3e139983758218ecf363 (patch)
tree0789efe7d412963f4e5a09b89b6329a40e2a5857
parent816addf2276c9b06b8a7d799f5caad672dd1c680 (diff)
downloadpaludis-8fe0374c9bb9f452bced3e139983758218ecf363.tar.gz
paludis-8fe0374c9bb9f452bced3e139983758218ecf363.tar.xz
Tidy up util/ somewhat
-rw-r--r--paludis/default_config.cc4
-rw-r--r--paludis/default_config.hh2
-rw-r--r--paludis/dep_list.cc4
-rw-r--r--paludis/package_database.cc2
-rw-r--r--paludis/portage_repository.cc5
-rw-r--r--paludis/qa/dep_any_check.cc2
-rw-r--r--paludis/util/attributes.cc21
-rw-r--r--paludis/util/attributes.hh6
-rw-r--r--paludis/util/compare.cc4
-rw-r--r--paludis/util/compare.hh37
-rw-r--r--paludis/util/comparison_policy.cc21
-rw-r--r--paludis/util/comparison_policy.hh.m438
-rw-r--r--paludis/util/composite_pattern.cc21
-rw-r--r--paludis/util/composite_pattern.hh2
-rw-r--r--paludis/util/container_entry.cc21
-rw-r--r--paludis/util/container_entry.hh10
-rw-r--r--paludis/util/create_insert_iterator.cc21
-rw-r--r--paludis/util/create_insert_iterator.hh123
-rw-r--r--paludis/util/create_insert_iterator_TEST.cc74
-rw-r--r--paludis/util/files.m416
-rw-r--r--paludis/util/filter_insert_iterator.cc22
-rw-r--r--paludis/util/filter_insert_iterator.hh134
-rw-r--r--paludis/util/filter_insert_iterator_TEST.cc83
-rw-r--r--paludis/util/indirect_iterator.cc21
-rw-r--r--paludis/util/indirect_iterator.hh161
-rw-r--r--paludis/util/iterator.hh517
-rw-r--r--paludis/util/iterator_TEST.cc (renamed from paludis/util/indirect_iterator_TEST.cc)197
-rw-r--r--paludis/util/iterator_utilities.cc21
-rw-r--r--paludis/util/iterator_utilities.hh46
-rw-r--r--paludis/util/iterator_utilities_TEST.cc83
-rw-r--r--paludis/util/transform_insert_iterator.cc21
-rw-r--r--paludis/util/transform_insert_iterator.hh157
-rw-r--r--paludis/util/transform_insert_iterator_TEST.cc96
-rw-r--r--paludis/util/virtual_constructor.hh2
-rw-r--r--paludis/util/visitor_TEST.cc2
-rw-r--r--paludis/version_metadata.cc3
36 files changed, 820 insertions, 1180 deletions
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index 3ebc379..ae3da3c 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -19,13 +19,11 @@
#include <paludis/config_file.hh>
#include <paludis/default_config.hh>
-#include <paludis/util/create_insert_iterator.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/dir_iterator.hh>
-#include <paludis/util/filter_insert_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/is_file_with_extension.hh>
-#include <paludis/util/iterator_utilities.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
diff --git a/paludis/default_config.hh b/paludis/default_config.hh
index c0244be..9e5fa76 100644
--- a/paludis/default_config.hh
+++ b/paludis/default_config.hh
@@ -25,7 +25,7 @@
#include <paludis/use_flag_state.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/indirect_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/smart_record.hh>
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index ce2fe18..4574e05 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -23,9 +23,7 @@
#include <paludis/dep_parser.hh>
#include <paludis/match_package.hh>
#include <paludis/util/container_entry.hh>
-#include <paludis/util/filter_insert_iterator.hh>
-#include <paludis/util/indirect_iterator.hh>
-#include <paludis/util/iterator_utilities.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index bf738e7..3c5d9d3 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -20,7 +20,7 @@
#include <paludis/dep_atom.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
-#include <paludis/util/indirect_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/stringify.hh>
#include <list>
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 9627aa3..1674e42 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -25,19 +25,16 @@
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/portage_repository.hh>
-#include <paludis/util/create_insert_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/dir_iterator.hh>
-#include <paludis/util/filter_insert_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/system.hh>
-#include <paludis/util/indirect_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/log.hh>
#include <paludis/util/pstream.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/tokeniser.hh>
-#include <paludis/util/transform_insert_iterator.hh>
#include <map>
#include <fstream>
diff --git a/paludis/qa/dep_any_check.cc b/paludis/qa/dep_any_check.cc
index 0969384..50804bd 100644
--- a/paludis/qa/dep_any_check.cc
+++ b/paludis/qa/dep_any_check.cc
@@ -21,7 +21,7 @@
#include <paludis/dep_parser.hh>
#include <paludis/dep_atom.hh>
-#include <paludis/util/iterator_utilities.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/save.hh>
using namespace paludis;
diff --git a/paludis/util/attributes.cc b/paludis/util/attributes.cc
deleted file mode 100644
index 075e465..0000000
--- a/paludis/util/attributes.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/attributes.hh>
-
diff --git a/paludis/util/attributes.hh b/paludis/util/attributes.hh
index bae079e..4e6b3f7 100644
--- a/paludis/util/attributes.hh
+++ b/paludis/util/attributes.hh
@@ -22,16 +22,22 @@
/** \file
* Declare the PALUDIS_ATTRIBUTE macro.
+ *
+ * \ingroup Utility
*/
/** \def PALUDIS_ATTRIBUTE
* If we're using a recent GCC or ICC, expands to __attribute__, otherwise
* discards its arguments.
+ *
+ * \ingroup Utility
*/
/** \def PALUDIS_CAN_USE_ATTRIBUTE
* Defined if we can rely upon PALUDIS_ATTRIBUTE working (for example, for
* weak).
+ *
+ * \ingroup Utility
*/
#if (defined(__GNUC__) || defined(DOXYGEN))
diff --git a/paludis/util/compare.cc b/paludis/util/compare.cc
deleted file mode 100644
index 7101107..0000000
--- a/paludis/util/compare.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-#include <paludis/util/compare.hh>
-
diff --git a/paludis/util/compare.hh b/paludis/util/compare.hh
index b209e6e..74d81a4 100644
--- a/paludis/util/compare.hh
+++ b/paludis/util/compare.hh
@@ -1,5 +1,22 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#ifndef PALUDIS_GUARD_PALUDIS_COMPARE_HH
#define PALUDIS_GUARD_PALUDIS_COMPARE_HH 1
@@ -7,12 +24,20 @@
#include <paludis/util/validated.hh>
#include <string>
+/** \file
+ * Declarations for the compare functions.
+ *
+ * \ingroup Utility
+ */
+
namespace paludis
{
/**
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
inline int compare(int t1, int t2) PALUDIS_ATTRIBUTE((always_inline));
@@ -30,6 +55,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
inline int compare(unsigned t1, unsigned t2) PALUDIS_ATTRIBUTE((always_inline));
@@ -47,6 +74,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
inline int long compare(unsigned long t1, unsigned long t2) PALUDIS_ATTRIBUTE((always_inline));
@@ -64,6 +93,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
inline int compare(long t1, long t2) PALUDIS_ATTRIBUTE((always_inline));
@@ -81,6 +112,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
template <typename T_>
inline int compare(
@@ -106,6 +139,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
template <typename T_, typename U_>
inline int compare(
@@ -119,6 +154,8 @@ namespace paludis
* Compare t1 and t2.
*
* \retval -1 if t1 < t2, 1 if t1 > t2, 0 otherwise.
+ *
+ * \ingroup Utility
*/
template <typename T_>
int compare(
diff --git a/paludis/util/comparison_policy.cc b/paludis/util/comparison_policy.cc
deleted file mode 100644
index f61918f..0000000
--- a/paludis/util/comparison_policy.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/comparison_policy.hh>
-
diff --git a/paludis/util/comparison_policy.hh.m4 b/paludis/util/comparison_policy.hh.m4
index b33f2f8..4eee9b4 100644
--- a/paludis/util/comparison_policy.hh.m4
+++ b/paludis/util/comparison_policy.hh.m4
@@ -24,15 +24,25 @@ dnl vim: set ft=cpp et sw=4 sts=4 :
#ifndef PALUDIS_GUARD_PALUDIS_COMPARISON_POLICY_HH
#define PALUDIS_GUARD_PALUDIS_COMPARISON_POLICY_HH 1
+/** \file
+ * Declarations for the ComparisonPolicy class.
+ *
+ * \ingroup Utility
+ */
+
namespace paludis
{
/**
* Comparison modes for paludis::ComparisonPolicy.
+ *
+ * \ingroup Utility
*/
namespace comparison_mode
{
/**
* No comparisons can be made.
+ *
+ * \ingroup Utility
*/
struct NoComparisonTag
{
@@ -40,6 +50,8 @@ namespace paludis
/**
* Comparisons can be made via operator== and operator!=.
+ *
+ * \ingroup Utility
*/
struct EqualityComparisonTag
{
@@ -47,6 +59,8 @@ namespace paludis
/**
* The full range of comparison operators is available.
+ *
+ * \ingroup Utility
*/
struct FullComparisonTag
{
@@ -55,11 +69,15 @@ namespace paludis
/**
* Comparison methods for paludis::ComparisonPolicy.
+ *
+ * \ingroup Utility
*/
namespace comparison_method
{
/**
* Comparisons are done via a member of type MemberType_.
+ *
+ * \ingroup Utility
*/
template <typename MemberType_>
struct CompareByMemberTag
@@ -70,6 +88,8 @@ namespace paludis
* Comparisons are done by a member function that returns an integer
* less than zero (less than), equal to zero (equal to) or greater than
* zero (greater than).
+ *
+ * \ingroup Utility
*/
struct CompareByMemberComparisonFunctionTag
{
@@ -79,6 +99,8 @@ namespace paludis
/**
* Comparisons are done via a member function that returns an item of
* type MemberType_.
+ *
+ * \ingroup Utility
*/
template <typename MemberType_>
struct CompareByMemberFetchFunctionTag
@@ -90,6 +112,8 @@ namespace paludis
/**
* ComparisonPolicy specifies the availabillity of comparison methods and
* the strategy used to do comparisons.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename ComparisonModeTag_, typename ComparisonMethodTag_>
struct ComparisonPolicy
@@ -102,6 +126,8 @@ namespace paludis
/**
* ComparisonPolicy: specialisation for NoComparisonTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename ComparisonMethodTag_>
class ComparisonPolicy<OurType_, comparison_mode::NoComparisonTag, ComparisonMethodTag_>
@@ -120,6 +146,8 @@ namespace paludis
/**
* ComparisonPolicy: specialisation for EqualityComparisonTag +
* CompareByMemberTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename MemberType_>
class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
@@ -166,6 +194,8 @@ make_operator(`!=')
/**
* ComparisonPolicy: specialisation for EqualityComparisonTag +
* CompareByMemberComparisonFunctionTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_>
class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
@@ -212,6 +242,8 @@ make_operator(`!=')
/**
* ComparisonPolicy: specialisation for FullComparisonTag +
* CompareByMemberTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename MemberType_>
class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
@@ -262,6 +294,8 @@ make_operator(`>')
/**
* ComparisonPolicy: specialisation for FullComparisonTag +
* CompareByMemberComparisonFunctionTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_>
class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
@@ -311,6 +345,8 @@ make_operator(`>')
/**
* ComparisonPolicy: specialisation for EqualityComparisonTag +
* CompareByMemberFetchFunctionTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename MemberType_>
class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
@@ -355,6 +391,8 @@ make_operator(`!=')
/**
* ComparisonPolicy: specialisation for FullComparisonTag +
* CompareByMemberFetchFunctionTag.
+ *
+ * \ingroup Utility
*/
template <typename OurType_, typename MemberType_>
class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
diff --git a/paludis/util/composite_pattern.cc b/paludis/util/composite_pattern.cc
deleted file mode 100644
index 9b9bdf3..0000000
--- a/paludis/util/composite_pattern.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/composite_pattern.hh>
-
diff --git a/paludis/util/composite_pattern.hh b/paludis/util/composite_pattern.hh
index fecb47c..705b1dc 100644
--- a/paludis/util/composite_pattern.hh
+++ b/paludis/util/composite_pattern.hh
@@ -31,6 +31,8 @@ namespace paludis
/**
* A Composite class represents both a class and a collection of
* child instances of the same class.
+ *
+ * \ingroup Utility
*/
template <typename ChildClass_, typename CompositeClass_ = ChildClass_>
class Composite
diff --git a/paludis/util/container_entry.cc b/paludis/util/container_entry.cc
deleted file mode 100644
index 928ec7c..0000000
--- a/paludis/util/container_entry.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/container_entry.hh>
-
diff --git a/paludis/util/container_entry.hh b/paludis/util/container_entry.hh
index 9533e51..cfee778 100644
--- a/paludis/util/container_entry.hh
+++ b/paludis/util/container_entry.hh
@@ -22,11 +22,19 @@
#include <list>
+/** \file
+ * Declarations for the ContainerEntry class.
+ *
+ * \ingroup Utility
+ */
+
namespace paludis
{
/**
* Hold an entry in a container for as long as our ContainerEntry instance
* is in scope (RAII, see \ref EffCpp item 13 or \ref TCppPL section 14.4).
+ *
+ * \ingroup Utility
*/
template <typename Container_>
struct ContainerEntry;
@@ -35,6 +43,8 @@ namespace paludis
* Hold an entry in a container for as long as our ContainerEntry instance
* is in scope (RAII, see \ref EffCpp item 13 or \ref TCppPL section 14.4;
* partial specialisation for std::list).
+ *
+ * \ingroup Utility
*/
template <typename Item_>
class ContainerEntry<std::list<Item_> >
diff --git a/paludis/util/create_insert_iterator.cc b/paludis/util/create_insert_iterator.cc
deleted file mode 100644
index fdd742b..0000000
--- a/paludis/util/create_insert_iterator.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/create_insert_iterator.hh>
-
diff --git a/paludis/util/create_insert_iterator.hh b/paludis/util/create_insert_iterator.hh
deleted file mode 100644
index 2e5fd05..0000000
--- a/paludis/util/create_insert_iterator.hh
+++ /dev/null
@@ -1,123 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_CREATE_INSERT_ITERATOR_HH
-#define PALUDIS_GUARD_PALUDIS_CREATE_INSERT_ITERATOR_HH 1
-
-#include <functional>
-#include <iterator>
-
-namespace paludis
-{
- /**
- * A CreateInsertIterator is an insert iterator that creates an object of
- * the specified type using the provided value.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Type_>
- class CreateInsertIterator :
- public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
- {
- private:
- Iter_ _i;
-
- public:
- /**
- * Fake a container_type to allow us to work with other iterator
- * adapters.
- */
- struct container_type
- {
- /// Our faked item type.
- typedef Type_ value_type;
- };
-
- /**
- * Constructor, from an iterator.
- */
- CreateInsertIterator(const Iter_ & i) :
- _i(i)
- {
- }
-
- /**
- * Copy constructor.
- */
- CreateInsertIterator(const CreateInsertIterator & other) :
- _i(other._i)
- {
- }
-
- /**
- * Assignment.
- */
- template <typename T_>
- const CreateInsertIterator & operator= (const T_ value)
- {
- *_i = Type_(value);
- return *this;
- }
-
- /**
- * Dereference.
- */
- CreateInsertIterator & operator* ()
- {
- return *this;
- }
-
- /**
- * Dereference arrow.
- */
- CreateInsertIterator * operator-> ()
- {
- return this;
- }
-
- /**
- * Increment.
- */
- CreateInsertIterator & operator++ ()
- {
- return *this;
- }
-
- /**
- * Increment.
- */
- CreateInsertIterator & operator++ (int)
- {
- return *this;
- }
- };
-
- /**
- * Convenience function: make a CreateInsertIterator.
- *
- * \ingroup Iterator
- */
- template <typename Type_, typename Iter_>
- CreateInsertIterator<Iter_, Type_> create_inserter(const Iter_ & i)
- {
- return CreateInsertIterator<Iter_, Type_>(i);
- }
-}
-
-#endif
diff --git a/paludis/util/create_insert_iterator_TEST.cc b/paludis/util/create_insert_iterator_TEST.cc
deleted file mode 100644
index 614ac04..0000000
--- a/paludis/util/create_insert_iterator_TEST.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <algorithm>
-#include <paludis/util/create_insert_iterator.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <vector>
-
-using namespace paludis;
-using namespace test;
-
-/** \file
- * Test cases for CreateInsertIterator.
- *
- * \ingroup Test
- * \ingroup Iterator
- */
-
-#ifndef DOXYGEN
-struct C
-{
- std::string s;
-
- explicit C(const std::string & ss) :
- s(ss)
- {
- }
-};
-#endif
-
-namespace test_cases
-{
- /**
- * \test Test create_inserter.
- *
- * \ingroup Test
- */
- struct CreateInsertIteratorTest : TestCase
- {
- CreateInsertIteratorTest() : TestCase("create insert iterator") { }
-
- void run()
- {
- std::vector<std::string> v;
- v.push_back("one");
- v.push_back("two");
-
- std::vector<C> vv;
- std::copy(v.begin(), v.end(), create_inserter<C>(std::back_inserter(vv)));
-
- TEST_CHECK_EQUAL(vv.size(), 2);
- TEST_CHECK_EQUAL(vv.at(0).s, "one");
- TEST_CHECK_EQUAL(vv.at(1).s, "two");
- }
- } test_create_insert_iterator;
-}
-
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 1d033c6..eb2e147 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -8,24 +8,21 @@ dnl the base filename with no extension; later parameters can be `hh', `cc',
dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
-add(`attributes', `hh', `cc')
-add(`compare', `hh', `cc')
-add(`comparison_policy', `hh', `cc', `test')
-add(`composite_pattern', `hh', `cc')
-add(`container_entry', `hh', `cc', `test')
+add(`attributes', `hh')
+add(`compare', `hh')
+add(`comparison_policy', `hh', `test')
+add(`composite_pattern', `hh')
+add(`container_entry', `hh', `test')
add(`counted_ptr', `hh', `cc', `test')
-add(`create_insert_iterator', `hh', `cc', `test')
add(`deleter', `hh', `cc', `test')
add(`destringify', `hh', `cc', `test')
add(`dir_iterator', `hh', `cc', `test', `testscript')
add(`exception', `hh', `cc')
-add(`filter_insert_iterator', `hh', `cc', `test')
add(`fs_entry', `hh', `cc', `test', `testscript')
-add(`indirect_iterator', `hh', `cc', `test')
+add(`iterator', `hh', `test')
add(`instantiation_policy', `hh', `cc', `test')
add(`is_const', `hh', `cc', `test')
add(`is_file_with_extension', `hh', `cc', `test', `testscript')
-add(`iterator_utilities', `hh', `cc', `test')
add(`join', `hh', `cc', `test')
add(`log', `hh', `cc', `test')
add(`private_implementation_pattern', `hh', `cc')
@@ -38,7 +35,6 @@ add(`stringify', `hh', `cc', `test')
add(`strip', `hh', `cc', `test')
add(`system', `hh', `cc', `test')
add(`tokeniser', `hh', `cc', `test')
-add(`transform_insert_iterator', `hh', `cc', `test')
add(`util', `hh')
add(`validated', `hh', `cc', `test')
add(`virtual_constructor', `hh', `cc', `test')
diff --git a/paludis/util/filter_insert_iterator.cc b/paludis/util/filter_insert_iterator.cc
deleted file mode 100644
index 95bdd59..0000000
--- a/paludis/util/filter_insert_iterator.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-#include <paludis/util/filter_insert_iterator.hh>
-
diff --git a/paludis/util/filter_insert_iterator.hh b/paludis/util/filter_insert_iterator.hh
deleted file mode 100644
index bf3a64b..0000000
--- a/paludis/util/filter_insert_iterator.hh
+++ /dev/null
@@ -1,134 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_FILTER_INSERT_ITERATOR_HH
-#define PALUDIS_GUARD_PALUDIS_FILTER_INSERT_ITERATOR_HH 1
-
-#include <functional>
-#include <iterator>
-
-namespace paludis
-{
- /**
- * A FilterInsertIterator is an insert iterator that only performs an insert
- * if a particular predicate function returns true for the object to be
- * inserted.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Pred_>
- class FilterInsertIterator :
- public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
- {
- private:
- Iter_ _i;
- Pred_ _p;
-
- public:
- /**
- * Fake a container_type for use with other iterator adapters.
- */
- typedef typename Iter_::container_type container_type;
-
- /**
- * Constructor, from an iterator.
- */
- FilterInsertIterator(const Iter_ & i, const Pred_ & p) :
- _i(i),
- _p(p)
- {
- }
-
- /**
- * Copy constructor.
- */
- FilterInsertIterator(const FilterInsertIterator & other) :
- _i(other._i),
- _p(other._p)
- {
- }
-
- /**
- * Assignment.
- */
- template <typename T_>
- const FilterInsertIterator & operator= (const T_ value)
- {
- if (_p(value))
- *_i = value;
- return *this;
- }
-
- /**
- * Destructor.
- */
- ~FilterInsertIterator();
-
- /**
- * Dereference.
- */
- FilterInsertIterator & operator* ()
- {
- return *this;
- }
-
- /**
- * Dereference arrow.
- */
- FilterInsertIterator * operator-> ()
- {
- return this;
- }
-
- /**
- * Increment.
- */
- FilterInsertIterator & operator++ ()
- {
- return *this;
- }
-
- /**
- * Increment.
- */
- FilterInsertIterator & operator++ (int)
- {
- return *this;
- }
- };
-
- template <typename Iter_, typename Pred_>
- FilterInsertIterator<Iter_, Pred_>::~FilterInsertIterator()
- {
- }
-
- /**
- * Convenience function: make a FilterInsertIterator.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Pred_>
- FilterInsertIterator<Iter_, Pred_> filter_inserter(
- const Iter_ & i, const Pred_ & p)
- {
- return FilterInsertIterator<Iter_, Pred_>(i, p);
- }
-}
-
-#endif
diff --git a/paludis/util/filter_insert_iterator_TEST.cc b/paludis/util/filter_insert_iterator_TEST.cc
deleted file mode 100644
index cbc62bb..0000000
--- a/paludis/util/filter_insert_iterator_TEST.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <algorithm>
-#include <paludis/util/filter_insert_iterator.hh>
-#include <set>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-#ifndef DOXYGEN
-struct Counter
-{
- int n;
-
- Counter() :
- n(0)
- {
- }
-
- int operator() ()
- {
- return n++;
- }
-};
-
-int is_even(const int & v)
-{
- return ! (v & 1);
-}
-#endif
-
-
-namespace test_cases
-{
- /**
- * \test Test FilterInsertIterator.
- *
- * \ingroup Test
- */
- struct FilterInsertIteratorTest : TestCase
- {
- FilterInsertIteratorTest() : TestCase("filter insert iterator") { }
-
- void run()
- {
- std::set<int> v;
- std::generate_n(filter_inserter(std::inserter(v, v.begin()), std::ptr_fun(&is_even)),
- 5, Counter());
- TEST_CHECK_EQUAL(v.size(), 3);
- for (int n = 0 ; n < 5 ; ++n)
- {
- TestMessageSuffix s("n=" + stringify(n));
- if (is_even(n))
- {
- TEST_CHECK(v.end() != v.find(n));
- TEST_CHECK_EQUAL(*v.find(n), n);
- }
- else
- TEST_CHECK(v.end() == v.find(n));
- }
- }
- } test_filter_insert_iterator;
-}
-
diff --git a/paludis/util/indirect_iterator.cc b/paludis/util/indirect_iterator.cc
deleted file mode 100644
index 6f05e27..0000000
--- a/paludis/util/indirect_iterator.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/indirect_iterator.hh>
-
diff --git a/paludis/util/indirect_iterator.hh b/paludis/util/indirect_iterator.hh
deleted file mode 100644
index affe8b6..0000000
--- a/paludis/util/indirect_iterator.hh
+++ /dev/null
@@ -1,161 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_INDIRECT_ITERATOR_HH
-#define PALUDIS_GUARD_PALUDIS_INDIRECT_ITERATOR_HH 1
-
-#include <iterator>
-#include <paludis/util/comparison_policy.hh>
-#include <paludis/util/instantiation_policy.hh>
-
-namespace paludis
-{
- template <typename Iter_, typename Value_>
- class IndirectIterator;
-
- namespace
- {
- /**
- * Determine the comparison class to use for IndirectIterator.
- */
- template <typename IterCategory_, typename Iter_, typename Value_>
- struct Comparisons
- {
- /**
- * Default to providing == and !=.
- */
- typedef ComparisonPolicy<IndirectIterator<Iter_, Value_>,
- comparison_mode::EqualityComparisonTag,
- comparison_method::CompareByMemberTag<Iter_> > Type;
- };
-
- /**
- * Determine the comparison class to use for IndirectIterator
- * (specialisation for random access iterators).
- */
- template <typename Iter_, typename Value_>
- struct Comparisons<std::random_access_iterator_tag, Iter_, Value_>
- {
- /**
- * Provide the full range of comparison operators.
- */
- typedef ComparisonPolicy<IndirectIterator<Iter_, Value_>,
- comparison_mode::FullComparisonTag,
- comparison_method::CompareByMemberTag<Iter_> > Type;
- };
- }
-
- /**
- * An IndirectIterator is an iterator adapter that does one additional level
- * of dereferencing.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Value_>
- class IndirectIterator : public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, Value_>,
- public Comparisons<typename std::iterator_traits<Iter_>::iterator_category,
- Iter_, Value_>::Type
- {
- private:
- Iter_ _i;
-
- public:
- /**
- * Constructor, from a base iterator.
- */
- IndirectIterator(const Iter_ & i) :
- Comparisons<typename std::iterator_traits<Iter_>::iterator_category, Iter_, Value_>::Type(
- &IndirectIterator<Iter_, Value_>::_i),
- _i(i)
- {
- }
-
- /**
- * Copy constructor.
- */
- IndirectIterator(const IndirectIterator & other) :
- Comparisons<typename std::iterator_traits<Iter_>::iterator_category, Iter_, Value_>::Type(
- &IndirectIterator<Iter_, Value_>::_i),
- _i(other._i)
- {
- }
-
- /**
- * Assignment.
- */
- const IndirectIterator & operator= (const IndirectIterator & other)
- {
- _i = other._i;
- return *this;
- }
-
- /**
- * Dereference.
- */
- Value_ & operator*()
- {
- return **_i;
- }
-
- /**
- * Dereference arrow.
- */
- Value_ * operator->()
- {
- return &**_i;
- }
-
- /**
- * Dereference, const.
- */
- const Value_ & operator*() const
- {
- return **_i;
- }
-
- /**
- * Dereference arrow, const.
- */
- const Value_ * operator->() const
- {
- return &**_i;
- }
-
- /**
- * Increment.
- */
- IndirectIterator & operator++ ()
- {
- ++_i;
- return *this;
- }
-
- /**
- * Increment.
- */
- IndirectIterator operator++ (int)
- {
- IndirectIterator tmp(*this);
- ++_i;
- return tmp;
- }
- };
-}
-
-#endif
diff --git a/paludis/util/iterator.hh b/paludis/util/iterator.hh
new file mode 100644
index 0000000..d6986b5
--- /dev/null
+++ b/paludis/util/iterator.hh
@@ -0,0 +1,517 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_INDIRECT_ITERATOR_HH
+#define PALUDIS_GUARD_PALUDIS_INDIRECT_ITERATOR_HH 1
+
+#include <iterator>
+#include <paludis/util/comparison_policy.hh>
+#include <paludis/util/instantiation_policy.hh>
+
+/** \file
+ * Declarations for various iterator helpers.
+ *
+ * \ingroup Iterator
+ */
+
+namespace paludis
+{
+ /**
+ * Return a new iterator pointing to the item after i.
+ *
+ * \ingroup Iterator
+ */
+ template <typename T_>
+ T_ next(const T_ & i)
+ {
+ T_ result(i);
+ return ++result;
+ }
+
+ /**
+ * Return a new iterator pointing to the item before i.
+ *
+ * \ingroup Iterator
+ */
+ template <typename T_>
+ T_ previous(const T_ & i)
+ {
+ T_ result(i);
+ return --result;
+ }
+
+ template <typename Iter_, typename Value_>
+ class IndirectIterator;
+
+ namespace
+ {
+ /**
+ * Determine the comparison class to use for IndirectIterator.
+ */
+ template <typename IterCategory_, typename Iter_, typename Value_>
+ struct Comparisons
+ {
+ /**
+ * Default to providing == and !=.
+ */
+ typedef ComparisonPolicy<IndirectIterator<Iter_, Value_>,
+ comparison_mode::EqualityComparisonTag,
+ comparison_method::CompareByMemberTag<Iter_> > Type;
+ };
+
+ /**
+ * Determine the comparison class to use for IndirectIterator
+ * (specialisation for random access iterators).
+ */
+ template <typename Iter_, typename Value_>
+ struct Comparisons<std::random_access_iterator_tag, Iter_, Value_>
+ {
+ /**
+ * Provide the full range of comparison operators.
+ */
+ typedef ComparisonPolicy<IndirectIterator<Iter_, Value_>,
+ comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberTag<Iter_> > Type;
+ };
+ }
+
+ /**
+ * An IndirectIterator is an iterator adapter that does one additional level
+ * of dereferencing.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Value_>
+ class IndirectIterator : public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, Value_>,
+ public Comparisons<typename std::iterator_traits<Iter_>::iterator_category,
+ Iter_, Value_>::Type
+ {
+ private:
+ Iter_ _i;
+
+ public:
+ /**
+ * Constructor, from a base iterator.
+ */
+ IndirectIterator(const Iter_ & i) :
+ Comparisons<typename std::iterator_traits<Iter_>::iterator_category, Iter_, Value_>::Type(
+ &IndirectIterator<Iter_, Value_>::_i),
+ _i(i)
+ {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ IndirectIterator(const IndirectIterator & other) :
+ Comparisons<typename std::iterator_traits<Iter_>::iterator_category, Iter_, Value_>::Type(
+ &IndirectIterator<Iter_, Value_>::_i),
+ _i(other._i)
+ {
+ }
+
+ /**
+ * Assignment.
+ */
+ const IndirectIterator & operator= (const IndirectIterator & other)
+ {
+ _i = other._i;
+ return *this;
+ }
+
+ /**
+ * Dereference.
+ */
+ Value_ & operator*()
+ {
+ return **_i;
+ }
+
+ /**
+ * Dereference arrow.
+ */
+ Value_ * operator->()
+ {
+ return &**_i;
+ }
+
+ /**
+ * Dereference, const.
+ */
+ const Value_ & operator*() const
+ {
+ return **_i;
+ }
+
+ /**
+ * Dereference arrow, const.
+ */
+ const Value_ * operator->() const
+ {
+ return &**_i;
+ }
+
+ /**
+ * Increment.
+ */
+ IndirectIterator & operator++ ()
+ {
+ ++_i;
+ return *this;
+ }
+
+ /**
+ * Increment.
+ */
+ IndirectIterator operator++ (int)
+ {
+ IndirectIterator tmp(*this);
+ ++_i;
+ return tmp;
+ }
+ };
+
+ /**
+ * A FilterInsertIterator is an insert iterator that only performs an insert
+ * if a particular predicate function returns true for the object to be
+ * inserted.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Pred_>
+ class FilterInsertIterator :
+ public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
+ {
+ private:
+ Iter_ _i;
+ Pred_ _p;
+
+ public:
+ /**
+ * Fake a container_type for use with other iterator adapters.
+ */
+ typedef typename Iter_::container_type container_type;
+
+ /**
+ * Constructor, from an iterator.
+ */
+ FilterInsertIterator(const Iter_ & i, const Pred_ & p) :
+ _i(i),
+ _p(p)
+ {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ FilterInsertIterator(const FilterInsertIterator & other) :
+ _i(other._i),
+ _p(other._p)
+ {
+ }
+
+ /**
+ * Assignment.
+ */
+ template <typename T_>
+ const FilterInsertIterator & operator= (const T_ value)
+ {
+ if (_p(value))
+ *_i = value;
+ return *this;
+ }
+
+ /**
+ * Destructor.
+ */
+ ~FilterInsertIterator();
+
+ /**
+ * Dereference.
+ */
+ FilterInsertIterator & operator* ()
+ {
+ return *this;
+ }
+
+ /**
+ * Dereference arrow.
+ */
+ FilterInsertIterator * operator-> ()
+ {
+ return this;
+ }
+
+ /**
+ * Increment.
+ */
+ FilterInsertIterator & operator++ ()
+ {
+ return *this;
+ }
+
+ /**
+ * Increment.
+ */
+ FilterInsertIterator & operator++ (int)
+ {
+ return *this;
+ }
+ };
+
+ template <typename Iter_, typename Pred_>
+ FilterInsertIterator<Iter_, Pred_>::~FilterInsertIterator()
+ {
+ }
+
+ /**
+ * Convenience function: make a FilterInsertIterator.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Pred_>
+ FilterInsertIterator<Iter_, Pred_> filter_inserter(
+ const Iter_ & i, const Pred_ & p)
+ {
+ return FilterInsertIterator<Iter_, Pred_>(i, p);
+ }
+
+ /**
+ * A TransformInsertIterator is an insert iterator that calls some function
+ * upon an item before inserting it.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Trans_>
+ class TransformInsertIterator :
+ public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
+ {
+ private:
+ Iter_ _i;
+ Trans_ _t;
+
+ public:
+ /**
+ * Fake a container_type entry to allow a TransformInsertIterator to
+ * work with other iterator adapters.
+ */
+ struct container_type
+ {
+ /// Our value type.
+ typedef typename Trans_::argument_type value_type;
+ };
+
+ /**
+ * Constructor, from an iterator.
+ */
+ TransformInsertIterator(const Iter_ & i, const Trans_ & t = Trans_()) :
+ _i(i),
+ _t(t)
+ {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ TransformInsertIterator(const TransformInsertIterator & other) :
+ _i(other._i),
+ _t(other._t)
+ {
+ }
+
+ /**
+ * Assignment.
+ */
+ template <typename T_>
+ const TransformInsertIterator & operator= (const T_ value)
+ {
+ *_i = _t(value);
+ return *this;
+ }
+
+ /**
+ * Dereference.
+ */
+ TransformInsertIterator & operator* ()
+ {
+ return *this;
+ }
+
+ /**
+ * Dereference arrow.
+ */
+ TransformInsertIterator * operator-> ()
+ {
+ return this;
+ }
+
+ /**
+ * Increment.
+ */
+ TransformInsertIterator & operator++ ()
+ {
+ return *this;
+ }
+
+ /**
+ * Increment.
+ */
+ TransformInsertIterator & operator++ (int)
+ {
+ return *this;
+ }
+
+ };
+
+ /**
+ * Convenience function: make a TransformInsertIterator.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Trans_>
+ TransformInsertIterator<Iter_, Trans_> transform_inserter(
+ const Iter_ & i, const Trans_ & t)
+ {
+ return TransformInsertIterator<Iter_, Trans_>(i, t);
+ }
+
+ /**
+ * Convenience class: select the first item of a pair.
+ */
+ template <typename A_, typename B_>
+ struct SelectFirst :
+ std::unary_function<A_, std::pair<A_, B_> >
+ {
+ /// Carry out the selection.
+ A_ operator() (const std::pair<A_, B_> & p) const
+ {
+ return p.first;
+ }
+ };
+
+ /**
+ * Convenience class: select the second item of a pair.
+ */
+ template <typename A_, typename B_>
+ struct SelectSecond :
+ std::unary_function<A_, std::pair<A_, B_> >
+ {
+ /// Carry out the selection.
+ A_ operator() (const std::pair<A_, B_> & p) const
+ {
+ return p.second;
+ }
+ };
+
+ /**
+ * A CreateInsertIterator is an insert iterator that creates an object of
+ * the specified type using the provided value.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Iter_, typename Type_>
+ class CreateInsertIterator :
+ public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
+ {
+ private:
+ Iter_ _i;
+
+ public:
+ /**
+ * Fake a container_type to allow us to work with other iterator
+ * adapters.
+ */
+ struct container_type
+ {
+ /// Our faked item type.
+ typedef Type_ value_type;
+ };
+
+ /**
+ * Constructor, from an iterator.
+ */
+ CreateInsertIterator(const Iter_ & i) :
+ _i(i)
+ {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ CreateInsertIterator(const CreateInsertIterator & other) :
+ _i(other._i)
+ {
+ }
+
+ /**
+ * Assignment.
+ */
+ template <typename T_>
+ const CreateInsertIterator & operator= (const T_ value)
+ {
+ *_i = Type_(value);
+ return *this;
+ }
+
+ /**
+ * Dereference.
+ */
+ CreateInsertIterator & operator* ()
+ {
+ return *this;
+ }
+
+ /**
+ * Dereference arrow.
+ */
+ CreateInsertIterator * operator-> ()
+ {
+ return this;
+ }
+
+ /**
+ * Increment.
+ */
+ CreateInsertIterator & operator++ ()
+ {
+ return *this;
+ }
+
+ /**
+ * Increment.
+ */
+ CreateInsertIterator & operator++ (int)
+ {
+ return *this;
+ }
+ };
+
+ /**
+ * Convenience function: make a CreateInsertIterator.
+ *
+ * \ingroup Iterator
+ */
+ template <typename Type_, typename Iter_>
+ CreateInsertIterator<Iter_, Type_> create_inserter(const Iter_ & i)
+ {
+ return CreateInsertIterator<Iter_, Type_>(i);
+ }
+}
+
+#endif
diff --git a/paludis/util/indirect_iterator_TEST.cc b/paludis/util/iterator_TEST.cc
index 3e983bb..d418118 100644
--- a/paludis/util/indirect_iterator_TEST.cc
+++ b/paludis/util/iterator_TEST.cc
@@ -21,16 +21,17 @@
#include <list>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/deleter.hh>
-#include <paludis/util/indirect_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <vector>
+#include <set>
using namespace test;
using namespace paludis;
/** \file
- * Test cases for IndirectIterator.
+ * Test cases for iterator utilities.
*
* \ingroup Test
*/
@@ -144,3 +145,195 @@ namespace test_cases
} test_indirect_iterator_list_p_int;
}
+#ifndef DOXYGEN
+struct Counter
+{
+ int n;
+
+ Counter() :
+ n(0)
+ {
+ }
+
+ int operator() ()
+ {
+ return n++;
+ }
+};
+
+int is_even(const int & v)
+{
+ return ! (v & 1);
+}
+#endif
+
+
+namespace test_cases
+{
+ /**
+ * \test Test FilterInsertIterator.
+ *
+ * \ingroup Test
+ */
+ struct FilterInsertIteratorTest : TestCase
+ {
+ FilterInsertIteratorTest() : TestCase("filter insert iterator") { }
+
+ void run()
+ {
+ std::set<int> v;
+ std::generate_n(filter_inserter(std::inserter(v, v.begin()), std::ptr_fun(&is_even)),
+ 5, Counter());
+ TEST_CHECK_EQUAL(v.size(), 3);
+ for (int n = 0 ; n < 5 ; ++n)
+ {
+ TestMessageSuffix s("n=" + stringify(n));
+ if (is_even(n))
+ {
+ TEST_CHECK(v.end() != v.find(n));
+ TEST_CHECK_EQUAL(*v.find(n), n);
+ }
+ else
+ TEST_CHECK(v.end() == v.find(n));
+ }
+ }
+ } test_filter_insert_iterator;
+
+ /**
+ * \test Test iterator_utilities next()
+ *
+ * \ingroup Test
+ */
+ struct IteratorNextTest : public TestCase
+ {
+ IteratorNextTest() : TestCase("iterator next()") { }
+
+ void run()
+ {
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ std::vector<int>::iterator iter(v.begin());
+
+ TEST_CHECK(*(next(iter)) == 2);
+ TEST_CHECK(next(next(iter)) == v.end());
+ iter = next(iter);
+ TEST_CHECK(++iter == v.end());
+ }
+ } test_iterator_next;
+
+ /**
+ * \test Test iterator_utilities previous()
+ *
+ * \ingroup Test
+ */
+ struct IteratorpreviousTest : public TestCase
+ {
+ IteratorpreviousTest() : TestCase("iterator previous()") { }
+
+ void run()
+ {
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ std::vector<int>::iterator iter(v.end());
+
+ TEST_CHECK(*(previous(iter)) == 2);
+ TEST_CHECK(previous(previous(iter)) == v.begin());
+ iter = previous(iter);
+ TEST_CHECK(--iter == v.begin());
+ }
+ } test_iterator_previous;
+}
+
+#ifndef DOXYGEN
+int f(const int & v)
+{
+ return -v;
+}
+#endif
+
+namespace test_cases
+{
+ /**
+ * \test Test TransformInsertIterator.
+ *
+ * \ingroup Test
+ */
+ struct TransformInsertIteratorTest : TestCase
+ {
+ TransformInsertIteratorTest() : TestCase("transform insert iterator") { }
+
+ void run()
+ {
+ std::vector<int> v;
+ std::generate_n(transform_inserter(std::back_inserter(v), std::ptr_fun(&f)),
+ 5, Counter());
+ TEST_CHECK_EQUAL(v.size(), 5);
+ for (int n = 0 ; n < 5 ; ++n)
+ {
+ TestMessageSuffix s("n=" + stringify(n));
+ TEST_CHECK_EQUAL(v.at(n), -n);
+ }
+ }
+ } test_transform_insert_iterator;
+
+ /**
+ * \test Test SelectFirst and SelectSecond.
+ *
+ * \ingroup Test
+ */
+ struct SimpleSelectPairTest : TestCase
+ {
+ SimpleSelectPairTest() : TestCase("Simple SelectFirst and SelectSecond") {}
+
+ void run()
+ {
+ std::pair<int,int> p(1,2);
+ SelectFirst<int,int> f;
+ SelectSecond<int,int> s;
+
+ TEST_CHECK(f(p) == 1);
+ TEST_CHECK(s(p) == 2);
+ }
+ } test_select_pair;
+}
+
+#ifndef DOXYGEN
+struct C
+{
+ std::string s;
+
+ explicit C(const std::string & ss) :
+ s(ss)
+ {
+ }
+};
+#endif
+
+namespace test_cases
+{
+ /**
+ * \test Test create_inserter.
+ *
+ * \ingroup Test
+ */
+ struct CreateInsertIteratorTest : TestCase
+ {
+ CreateInsertIteratorTest() : TestCase("create insert iterator") { }
+
+ void run()
+ {
+ std::vector<std::string> v;
+ v.push_back("one");
+ v.push_back("two");
+
+ std::vector<C> vv;
+ std::copy(v.begin(), v.end(), create_inserter<C>(std::back_inserter(vv)));
+
+ TEST_CHECK_EQUAL(vv.size(), 2);
+ TEST_CHECK_EQUAL(vv.at(0).s, "one");
+ TEST_CHECK_EQUAL(vv.at(1).s, "two");
+ }
+ } test_create_insert_iterator;
+}
diff --git a/paludis/util/iterator_utilities.cc b/paludis/util/iterator_utilities.cc
deleted file mode 100644
index 97fd202..0000000
--- a/paludis/util/iterator_utilities.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/iterator_utilities.hh>
-
diff --git a/paludis/util/iterator_utilities.hh b/paludis/util/iterator_utilities.hh
deleted file mode 100644
index b24447e..0000000
--- a/paludis/util/iterator_utilities.hh
+++ /dev/null
@@ -1,46 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_ITERATOR_UTILITIES_HH
-#define PALUDIS_GUARD_PALUDIS_ITERATOR_UTILITIES_HH 1
-
-namespace paludis
-{
- /**
- * Return a new iterator pointing to the item after i.
- */
- template <typename T_>
- T_ next(const T_ & i)
- {
- T_ result(i);
- return ++result;
- }
-
- /**
- * Return a new iterator pointing to the item before i.
- */
- template <typename T_>
- T_ previous(const T_ & i)
- {
- T_ result(i);
- return --result;
- }
-}
-
-#endif
diff --git a/paludis/util/iterator_utilities_TEST.cc b/paludis/util/iterator_utilities_TEST.cc
deleted file mode 100644
index d3b12ec..0000000
--- a/paludis/util/iterator_utilities_TEST.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/iterator_utilities.hh>
-#include <string>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <vector>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for iterator_utilities.hh .
- *
- * \ingroup Test
- */
-
-namespace test_cases
-{
- /**
- * \test Test iterator_utilities next()
- *
- * \ingroup Test
- */
- struct IteratorNextTest : public TestCase
- {
- IteratorNextTest() : TestCase("iterator next()") { }
-
- void run()
- {
- std::vector<int> v;
- v.push_back(1);
- v.push_back(2);
- std::vector<int>::iterator iter(v.begin());
-
- TEST_CHECK(*(next(iter)) == 2);
- TEST_CHECK(next(next(iter)) == v.end());
- iter = next(iter);
- TEST_CHECK(++iter == v.end());
- }
- } test_iterator_next;
-
- /**
- * \test Test iterator_utilities previous()
- *
- * \ingroup Test
- */
- struct IteratorpreviousTest : public TestCase
- {
- IteratorpreviousTest() : TestCase("iterator previous()") { }
-
- void run()
- {
- std::vector<int> v;
- v.push_back(1);
- v.push_back(2);
- std::vector<int>::iterator iter(v.end());
-
- TEST_CHECK(*(previous(iter)) == 2);
- TEST_CHECK(previous(previous(iter)) == v.begin());
- iter = previous(iter);
- TEST_CHECK(--iter == v.begin());
- }
- } test_iterator_previous;
-}
-
diff --git a/paludis/util/transform_insert_iterator.cc b/paludis/util/transform_insert_iterator.cc
deleted file mode 100644
index 6cfa71c..0000000
--- a/paludis/util/transform_insert_iterator.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/transform_insert_iterator.hh>
-
diff --git a/paludis/util/transform_insert_iterator.hh b/paludis/util/transform_insert_iterator.hh
deleted file mode 100644
index 7488da8..0000000
--- a/paludis/util/transform_insert_iterator.hh
+++ /dev/null
@@ -1,157 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_TRANSFORM_INSERT_ITERATOR_HH
-#define PALUDIS_GUARD_PALUDIS_TRANSFORM_INSERT_ITERATOR_HH 1
-
-#include <functional>
-#include <iterator>
-
-namespace paludis
-{
- /**
- * A TransformInsertIterator is an insert iterator that calls some function
- * upon an item before inserting it.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Trans_>
- class TransformInsertIterator :
- public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, void, void, void, void>
- {
- private:
- Iter_ _i;
- Trans_ _t;
-
- public:
- /**
- * Fake a container_type entry to allow a TransformInsertIterator to
- * work with other iterator adapters.
- */
- struct container_type
- {
- /// Our value type.
- typedef typename Trans_::argument_type value_type;
- };
-
- /**
- * Constructor, from an iterator.
- */
- TransformInsertIterator(const Iter_ & i, const Trans_ & t = Trans_()) :
- _i(i),
- _t(t)
- {
- }
-
- /**
- * Copy constructor.
- */
- TransformInsertIterator(const TransformInsertIterator & other) :
- _i(other._i),
- _t(other._t)
- {
- }
-
- /**
- * Assignment.
- */
- template <typename T_>
- const TransformInsertIterator & operator= (const T_ value)
- {
- *_i = _t(value);
- return *this;
- }
-
- /**
- * Dereference.
- */
- TransformInsertIterator & operator* ()
- {
- return *this;
- }
-
- /**
- * Dereference arrow.
- */
- TransformInsertIterator * operator-> ()
- {
- return this;
- }
-
- /**
- * Increment.
- */
- TransformInsertIterator & operator++ ()
- {
- return *this;
- }
-
- /**
- * Increment.
- */
- TransformInsertIterator & operator++ (int)
- {
- return *this;
- }
-
- };
-
- /**
- * Convenience function: make a TransformInsertIterator.
- *
- * \ingroup Iterator
- */
- template <typename Iter_, typename Trans_>
- TransformInsertIterator<Iter_, Trans_> transform_inserter(
- const Iter_ & i, const Trans_ & t)
- {
- return TransformInsertIterator<Iter_, Trans_>(i, t);
- }
-
- /**
- * Convenience class: select the first item of a pair.
- */
- template <typename A_, typename B_>
- struct SelectFirst :
- std::unary_function<A_, std::pair<A_, B_> >
- {
- /// Carry out the selection.
- A_ operator() (const std::pair<A_, B_> & p) const
- {
- return p.first;
- }
- };
-
- /**
- * Convenience class: select the second item of a pair.
- */
- template <typename A_, typename B_>
- struct SelectSecond :
- std::unary_function<A_, std::pair<A_, B_> >
- {
- /// Carry out the selection.
- A_ operator() (const std::pair<A_, B_> & p) const
- {
- return p.second;
- }
- };
-
-}
-
-#endif
diff --git a/paludis/util/transform_insert_iterator_TEST.cc b/paludis/util/transform_insert_iterator_TEST.cc
deleted file mode 100644
index ace1bd2..0000000
--- a/paludis/util/transform_insert_iterator_TEST.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <algorithm>
-#include <paludis/util/transform_insert_iterator.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <vector>
-
-using namespace paludis;
-using namespace test;
-
-#ifndef DOXYGEN
-struct Counter
-{
- int n;
-
- Counter() :
- n(0)
- {
- }
-
- int operator() ()
- {
- return n++;
- }
-};
-
-int f(const int & v)
-{
- return -v;
-}
-#endif
-
-namespace test_cases
-{
- /**
- * \test Test TransformInsertIterator.
- *
- * \ingroup Test
- */
- struct TransformInsertIteratorTest : TestCase
- {
- TransformInsertIteratorTest() : TestCase("transform insert iterator") { }
-
- void run()
- {
- std::vector<int> v;
- std::generate_n(transform_inserter(std::back_inserter(v), std::ptr_fun(&f)),
- 5, Counter());
- TEST_CHECK_EQUAL(v.size(), 5);
- for (int n = 0 ; n < 5 ; ++n)
- {
- TestMessageSuffix s("n=" + stringify(n));
- TEST_CHECK_EQUAL(v.at(n), -n);
- }
- }
- } test_transform_insert_iterator;
-
- /**
- * \test Test SelectFirst and SelectSecond.
- *
- * \ingroup Test
- */
- struct SimpleSelectPairTest : TestCase
- {
- SimpleSelectPairTest() : TestCase("Simple SelectFirst and SelectSecond") {}
-
- void run()
- {
- std::pair<int,int> p(1,2);
- SelectFirst<int,int> f;
- SelectSecond<int,int> s;
-
- TEST_CHECK(f(p) == 1);
- TEST_CHECK(s(p) == 2);
- }
- } test_select_pair;
-}
-
diff --git a/paludis/util/virtual_constructor.hh b/paludis/util/virtual_constructor.hh
index 827181e..5e97763 100644
--- a/paludis/util/virtual_constructor.hh
+++ b/paludis/util/virtual_constructor.hh
@@ -23,7 +23,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/stringify.hh>
-#include <paludis/util/transform_insert_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <algorithm>
#include <vector>
diff --git a/paludis/util/visitor_TEST.cc b/paludis/util/visitor_TEST.cc
index 386eb2f..9155e73 100644
--- a/paludis/util/visitor_TEST.cc
+++ b/paludis/util/visitor_TEST.cc
@@ -19,7 +19,7 @@
#include <algorithm>
#include <paludis/util/deleter.hh>
-#include <paludis/util/indirect_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/visitor.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/version_metadata.cc b/paludis/version_metadata.cc
index 87a79a6..fd4c01b 100644
--- a/paludis/version_metadata.cc
+++ b/paludis/version_metadata.cc
@@ -17,8 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/util/create_insert_iterator.hh>
-#include <paludis/util/create_insert_iterator.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/version_metadata.hh>
#include <vector>