diff options
author | 2011-02-06 16:59:44 +0000 | |
---|---|---|
committer | 2011-02-06 16:59:44 +0000 | |
commit | 6c0be85967f3cd0bfdd21689fd9b1331bf798675 (patch) | |
tree | 34e9f92798832b1277c52b4841074f6d276368b0 | |
parent | b38149a7b9859f1ea04c854127dafcfd0746ce83 (diff) | |
download | paludis-6c0be85967f3cd0bfdd21689fd9b1331bf798675.tar.gz paludis-6c0be85967f3cd0bfdd21689fd9b1331bf798675.tar.xz |
No longer used
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | paludis/repositories/e/vdb_repository.cc | 1 | ||||
-rw-r--r-- | paludis/util/fast_unique_copy.hh | 88 | ||||
-rw-r--r-- | paludis/util/fast_unique_copy_TEST.cc | 121 | ||||
-rw-r--r-- | paludis/util/files.m4 | 2 | ||||
-rw-r--r-- | paludis/util/forward_parallel_for_each.hh | 96 | ||||
-rw-r--r-- | paludis/util/forward_parallel_for_each_TEST.cc | 58 |
7 files changed, 0 insertions, 368 deletions
diff --git a/.gitignore b/.gitignore index 946b32dee..2e8668ddb 100644 --- a/.gitignore +++ b/.gitignore @@ -439,8 +439,6 @@ paludis-*.*.*.tar.bz2 /paludis/util/echo_functions.bash /paludis/util/enum_iterator_TEST /paludis/util/extract_host_from_url_TEST -/paludis/util/fast_unique_copy_TEST -/paludis/util/forward_parallel_for_each_TEST /paludis/util/fs_entry_TEST /paludis/util/fs_iterator_TEST /paludis/util/fs_path_TEST diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index d1cbc8862..ba5bd066c 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -57,7 +57,6 @@ #include <paludis/unformatted_pretty_printer.hh> #include <paludis/util/accept_visitor.hh> -#include <paludis/util/fast_unique_copy.hh> #include <paludis/util/mutex.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/log.hh> diff --git a/paludis/util/fast_unique_copy.hh b/paludis/util/fast_unique_copy.hh deleted file mode 100644 index e716f9ee1..000000000 --- a/paludis/util/fast_unique_copy.hh +++ /dev/null @@ -1,88 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007, 2009 Ciaran McCreesh - * - * 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_REPOSITORIES_VIRTUALS_FAST_UNIQUE_COPY_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_VIRTUALS_FAST_UNIQUE_COPY_HH 1 - -#include <paludis/util/iterator_funcs.hh> -#include <functional> - -namespace paludis -{ - /** - * For use by fast_unique_copy only. - */ - namespace fast_unique_copy_internals - { - /** - * For use by fast_unique_copy only. - */ - template <typename I_, typename O_, typename C_> - void - real_fast_unique_copy(const I_ & start, const I_ & end, const I_ & full_end, O_ out, - C_ comp, const I_ & mbgt) - { - if (start != end) - { - // if our final item is less than or equal to mbgt, there're no - // matches in this block - if ((mbgt != full_end) && ((comp(*previous(end), *mbgt)) || (! comp(*mbgt, *previous(end))))) - return; - - // if our first item is equal to our last item, we have exactly - // one unique item in this sequence - if ((! comp(*start, *previous(end))) && (! comp(*previous(end), *start))) - { - *out = *start; - ++out; - } - else - { - I_ mid = start + (std::distance(start, end) >> 1); - real_fast_unique_copy(start, mid, full_end, out, comp, mbgt); - real_fast_unique_copy(mid, end, full_end, out, comp, previous(mid)); - } - } - } - } - - /** - * Extract unique elements from a sorted range of random access iterators. - */ - template <typename I_, typename O_> - void - fast_unique_copy(const I_ & start, const I_ & end, O_ out) - { - fast_unique_copy_internals::real_fast_unique_copy(start, end, end, out, - std::less<typename std::iterator_traits<I_>::value_type>(), - end); - } - - /** - * Extract unique elements from a sorted range of random access iterators. - */ - template <typename I_, typename O_, typename C_> - void - fast_unique_copy(const I_ & start, const I_ & end, O_ out, C_ comp) - { - fast_unique_copy_internals::real_fast_unique_copy(start, end, end, out, comp, end); - } -} - -#endif diff --git a/paludis/util/fast_unique_copy_TEST.cc b/paludis/util/fast_unique_copy_TEST.cc deleted file mode 100644 index f946591f3..000000000 --- a/paludis/util/fast_unique_copy_TEST.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Ciaran McCreesh - * - * 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 "fast_unique_copy.hh" -#include <test/test_framework.hh> -#include <test/test_runner.hh> -#include <paludis/util/join.hh> -#include <vector> - -using namespace test; -using namespace paludis; - -namespace test_cases -{ - struct FastUniqueCopySimpleSequenceTest : TestCase - { - FastUniqueCopySimpleSequenceTest() : TestCase("fast_unique_copy simple sequence") { } - - void run() - { - for (unsigned sz = 0 ; sz < 20 ; ++sz) - { - TestMessageSuffix s("sz=" + stringify(sz)); - std::vector<unsigned> v; - for (unsigned x = 0 ; x < sz ; ++x) - v.push_back(x); - - std::vector<unsigned> r; - fast_unique_copy(v.begin(), v.end(), std::back_inserter(r), std::less<int>()); - - TestMessageSuffix vs("v=" + join(v.begin(), v.end(), ",")); - TestMessageSuffix rs("r=" + join(r.begin(), r.end(), ",")); - - TEST_CHECK_EQUAL(r.size(), sz); - for (unsigned x = 0 ; x < sz ; ++x) - TEST_CHECK_EQUAL(r[x], x); - } - } - - } test_fast_unique_copy_simple_sequence; - - struct FastUniqueCopyRepeatedElementTest : TestCase - { - FastUniqueCopyRepeatedElementTest() : TestCase("fast_unique_copy single repeated element") { } - - void run() - { - for (unsigned sz = 0 ; sz < 20 ; ++sz) - { - TestMessageSuffix s("sz=" + stringify(sz)); - std::vector<unsigned> v; - for (unsigned x = 0 ; x < sz ; ++x) - v.push_back(42); - - std::vector<unsigned> r; - fast_unique_copy(v.begin(), v.end(), std::back_inserter(r)); - - TestMessageSuffix vs("v=" + join(v.begin(), v.end(), ",")); - TestMessageSuffix rs("r=" + join(r.begin(), r.end(), ",")); - - if (sz == 0) - TEST_CHECK_EQUAL(r.size(), std::size_t(0)); - else - { - TEST_CHECK_EQUAL(r.size(), std::size_t(1)); - TEST_CHECK_EQUAL(r[0], 42u); - } - } - } - - } test_fast_unique_copy_repeated_element; - - struct FastUniqueCopyNxNTest : TestCase - { - FastUniqueCopyNxNTest() : TestCase("fast_unique_copy nxn") { } - - void run() - { - for (unsigned sz = 0 ; sz < 20 ; ++sz) - { - TestMessageSuffix s("sz=" + stringify(sz)); - std::vector<unsigned> v; - for (unsigned x = 0 ; x < sz ; ++x) - for (unsigned y = 0 ; y < x ; ++y) - v.push_back(x); - - std::vector<unsigned> r; - fast_unique_copy(v.begin(), v.end(), std::back_inserter(r)); - - TestMessageSuffix vs("v=" + join(v.begin(), v.end(), ",")); - TestMessageSuffix rs("r=" + join(r.begin(), r.end(), ",")); - if (sz == 0) - TEST_CHECK_EQUAL(r.size(), std::size_t(0)); - else - { - TEST_CHECK_EQUAL(r.size(), sz - 1); - for (unsigned x = 0 ; x < sz - 1 ; ++x) - TEST_CHECK_EQUAL(r[x], x + 1); - } - } - } - - } test_fast_unique_copy_nxn; -} - diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index c84ff3661..00962b018 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -35,9 +35,7 @@ add(`enum_iterator', `hh', `cc', `fwd', `test') add(`exception', `hh', `cc') add(`executor', `hh', `cc', `fwd') add(`extract_host_from_url', `hh', `cc', `fwd', `test') -add(`fast_unique_copy', `hh', `test') add(`fd_holder', `hh') -add(`forward_parallel_for_each', `hh', `test') add(`fs_iterator', `hh', `cc', `fwd', `se', `test', `testscript') add(`fs_error', `hh', `cc') add(`fs_path', `hh', `cc', `fwd', `se', `test', `testscript') diff --git a/paludis/util/forward_parallel_for_each.hh b/paludis/util/forward_parallel_for_each.hh deleted file mode 100644 index f764583ed..000000000 --- a/paludis/util/forward_parallel_for_each.hh +++ /dev/null @@ -1,96 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2009 Ciaran McCreesh - * - * 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_UTIL_FORWARD_PARALLEL_FOR_EACH_HH -#define PALUDIS_GUARD_PALUDIS_UTIL_FORWARD_PARALLEL_FOR_EACH_HH 1 - -#include <paludis/util/mutex.hh> -#include <paludis/util/thread_pool.hh> -#include <functional> - -/** \file - * Declarations for the forward_parallel_for_each function. - * - * \ingroup g_threads - * - * \section Examples - * - * - None at this time. - */ - -namespace paludis -{ - /** - * For forward_parallel_for_each. - * - * \see forward_parallel_for_each - * \since 0.36 - * \ingroup g_threads - */ - template <typename Iter_, typename Func_> - void forward_parallel_for_each_thread_func(Iter_ & cur, const Iter_ & end, Mutex & mutex, Func_ & func, - unsigned n_at_once) - { - while (true) - { - unsigned n_to_do(0); - Iter_ i(end); - { - Lock lock(mutex); - if (cur == end) - return; - - i = cur; - while (n_to_do < n_at_once && cur != end) - { - ++cur; - ++n_to_do; - } - } - - for (unsigned n(0) ; n < n_to_do ; ++n) - func(*i++); - } - } - - /** - * Like std::for_each, but in parallel, and no return value. - * - * This works for forward iterators, but is only effective if each - * calculation is quite slow. - * - * \since 0.36 - * \ingroup g_threads - */ - template <typename Iter_, typename Func_> - void forward_parallel_for_each(Iter_ cur, const Iter_ & end, Func_ func, unsigned n_threads, unsigned n_at_once) - { - if (cur == end) - return; - - Mutex mutex; - ThreadPool threads; - - for (unsigned n(0) ; n != n_threads ; ++n) - threads.create_thread(std::bind(&forward_parallel_for_each_thread_func<Iter_, Func_>, std::ref(cur), - std::cref(end), std::ref(mutex), std::ref(func), n_at_once)); - } -} - -#endif diff --git a/paludis/util/forward_parallel_for_each_TEST.cc b/paludis/util/forward_parallel_for_each_TEST.cc deleted file mode 100644 index 53c821871..000000000 --- a/paludis/util/forward_parallel_for_each_TEST.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2009 Ciaran McCreesh - * - * 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/forward_parallel_for_each.hh> -#include <test/test_runner.hh> -#include <test/test_framework.hh> -#include <vector> -#include <algorithm> - -using namespace test; -using namespace paludis; - -namespace -{ - void inc(int & b) throw () - { - ++b; - } -} - -namespace test_cases -{ - struct ForwardParallelForEachTest : TestCase - { - ForwardParallelForEachTest() : TestCase("forward_parallel_for_each") { } - - void run() - { - std::vector<int> t(1000, 0); - - forward_parallel_for_each(t.begin(), t.end(), inc, 10, 1); - TEST_CHECK(1000 == std::count(t.begin(), t.end(), 1)); - - forward_parallel_for_each(t.begin(), t.end(), inc, 1, 100); - TEST_CHECK(1000 == std::count(t.begin(), t.end(), 2)); - - forward_parallel_for_each(t.begin(), t.end(), inc, 10, 10); - TEST_CHECK(1000 == std::count(t.begin(), t.end(), 3)); - } - } test_forward_parallel_for_each; -} - |