yat/normalizer/utility.h

Code
Comments
Other
Rev Date Author Line
2155 17 Jan 10 peter 1 #ifndef _theplu_yat_normalizer_utility_
3541 23 Dec 16 peter 2 #define _theplu_yat_normalizer_utility_
2155 17 Jan 10 peter 3
2155 17 Jan 10 peter 4 // $Id$
2155 17 Jan 10 peter 5
2155 17 Jan 10 peter 6 /*
4359 23 Aug 23 peter 7   Copyright (C) 2010, 2016 Peter Johansson
2155 17 Jan 10 peter 8
2155 17 Jan 10 peter 9   This file is part of the yat library, http://dev.thep.lu.se/yat
2155 17 Jan 10 peter 10
2155 17 Jan 10 peter 11   The yat library is free software; you can redistribute it and/or
2155 17 Jan 10 peter 12   modify it under the terms of the GNU General Public License as
2155 17 Jan 10 peter 13   published by the Free Software Foundation; either version 3 of the
2155 17 Jan 10 peter 14   License, or (at your option) any later version.
2155 17 Jan 10 peter 15
2155 17 Jan 10 peter 16   The yat library is distributed in the hope that it will be useful,
2155 17 Jan 10 peter 17   but WITHOUT ANY WARRANTY; without even the implied warranty of
2155 17 Jan 10 peter 18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2155 17 Jan 10 peter 19   General Public License for more details.
2155 17 Jan 10 peter 20
2155 17 Jan 10 peter 21   You should have received a copy of the GNU General Public License
2155 17 Jan 10 peter 22   along with yat. If not, see <http://www.gnu.org/licenses/>.
2155 17 Jan 10 peter 23 */
2155 17 Jan 10 peter 24
3541 23 Dec 16 peter 25 #include "yat/utility/concept_check.h"
2155 17 Jan 10 peter 26 #include "yat/utility/iterator_traits.h"
2155 17 Jan 10 peter 27 #include "yat/utility/WeightIterator.h"
2155 17 Jan 10 peter 28
3541 23 Dec 16 peter 29 #include <boost/concept_check.hpp>
3541 23 Dec 16 peter 30
2155 17 Jan 10 peter 31 #include <algorithm>
2155 17 Jan 10 peter 32
2155 17 Jan 10 peter 33 namespace theplu {
2155 17 Jan 10 peter 34 namespace yat {
2155 17 Jan 10 peter 35 namespace normalizer {
2155 17 Jan 10 peter 36
2155 17 Jan 10 peter 37 // internal functions in namespace detail
2155 17 Jan 10 peter 38 namespace detail {
2155 17 Jan 10 peter 39   template<typename InputIterator, typename OutputIterator>
2155 17 Jan 10 peter 40   void copy_weight_if_weighted(InputIterator first, InputIterator last,
4200 19 Aug 22 peter 41                                OutputIterator result,
2155 17 Jan 10 peter 42                                utility::unweighted_iterator_tag tag)
2155 17 Jan 10 peter 43   {
2155 17 Jan 10 peter 44   }
2155 17 Jan 10 peter 45
2155 17 Jan 10 peter 46   template<typename InputIterator, typename OutputIterator>
2155 17 Jan 10 peter 47   void copy_weight_if_weighted(InputIterator first, InputIterator last,
4200 19 Aug 22 peter 48                                OutputIterator result,
2155 17 Jan 10 peter 49                                utility::weighted_iterator_tag tag)
2155 17 Jan 10 peter 50   {
2155 17 Jan 10 peter 51     using utility::weight_iterator;
4200 19 Aug 22 peter 52     std::copy(weight_iterator(first), weight_iterator(last),
2155 17 Jan 10 peter 53               weight_iterator(result));
2155 17 Jan 10 peter 54   }
2155 17 Jan 10 peter 55
2155 17 Jan 10 peter 56   /**
2155 17 Jan 10 peter 57      internal function
2155 17 Jan 10 peter 58
2155 17 Jan 10 peter 59      if \a result is weighted copy weights from [first, last) else do nothing
2155 17 Jan 10 peter 60    */
2155 17 Jan 10 peter 61   template<typename InputIterator, typename OutputIterator>
2155 17 Jan 10 peter 62   void copy_weight_if_weighted(InputIterator first, InputIterator last,
2155 17 Jan 10 peter 63                                OutputIterator result)
2155 17 Jan 10 peter 64   {
3541 23 Dec 16 peter 65     BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<OutputIterator>));
2155 17 Jan 10 peter 66     typename utility::weighted_iterator_traits<OutputIterator>::type tag;
2155 17 Jan 10 peter 67     copy_weight_if_weighted(first, last, result, tag);
2155 17 Jan 10 peter 68   }
2155 17 Jan 10 peter 69 } // of namespace detail
2155 17 Jan 10 peter 70
2155 17 Jan 10 peter 71 }}} // of namespace normalizer, yat, and theplu
2155 17 Jan 10 peter 72
2155 17 Jan 10 peter 73 #endif