Chris@16
|
1 #ifndef BOOST_ALGORITHM_RG071801_HPP
|
Chris@16
|
2 #define BOOST_ALGORITHM_RG071801_HPP
|
Chris@16
|
3
|
Chris@16
|
4 //
|
Chris@16
|
5 //
|
Chris@16
|
6 // Copyright (c) 1994
|
Chris@16
|
7 // Hewlett-Packard Company
|
Chris@16
|
8 //
|
Chris@16
|
9 // Permission to use, copy, modify, distribute and sell this software
|
Chris@16
|
10 // and its documentation for any purpose is hereby granted without fee,
|
Chris@16
|
11 // provided that the above copyright notice appear in all copies and
|
Chris@16
|
12 // that both that copyright notice and this permission notice appear
|
Chris@16
|
13 // in supporting documentation. Hewlett-Packard Company makes no
|
Chris@16
|
14 // representations about the suitability of this software for any
|
Chris@16
|
15 // purpose. It is provided "as is" without express or implied warranty.
|
Chris@16
|
16 //
|
Chris@16
|
17 //
|
Chris@16
|
18 // Copyright (c) 1996-1998
|
Chris@16
|
19 // Silicon Graphics Computer Systems, Inc.
|
Chris@16
|
20 //
|
Chris@16
|
21 // Permission to use, copy, modify, distribute and sell this software
|
Chris@16
|
22 // and its documentation for any purpose is hereby granted without fee,
|
Chris@16
|
23 // provided that the above copyright notice appear in all copies and
|
Chris@16
|
24 // that both that copyright notice and this permission notice appear
|
Chris@16
|
25 // in supporting documentation. Silicon Graphics makes no
|
Chris@16
|
26 // representations about the suitability of this software for any
|
Chris@16
|
27 // purpose. It is provided "as is" without express or implied warranty.
|
Chris@16
|
28 //
|
Chris@16
|
29
|
Chris@16
|
30 // Copyright 2002 The Trustees of Indiana University.
|
Chris@16
|
31
|
Chris@16
|
32 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
33 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
34 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
35
|
Chris@16
|
36 // Boost.MultiArray Library
|
Chris@16
|
37 // Authors: Ronald Garcia
|
Chris@16
|
38 // Jeremy Siek
|
Chris@16
|
39 // Andrew Lumsdaine
|
Chris@16
|
40 // See http://www.boost.org/libs/multi_array for documentation.
|
Chris@16
|
41
|
Chris@16
|
42
|
Chris@16
|
43 #include "boost/iterator.hpp"
|
Chris@16
|
44
|
Chris@16
|
45 namespace boost {
|
Chris@16
|
46 namespace detail {
|
Chris@16
|
47 namespace multi_array {
|
Chris@16
|
48 //--------------------------------------------------
|
Chris@16
|
49 // copy_n (not part of the C++ standard)
|
Chris@16
|
50 #if 1
|
Chris@16
|
51
|
Chris@16
|
52 template <class InputIter, class Size, class OutputIter>
|
Chris@16
|
53 OutputIter copy_n(InputIter first, Size count,
|
Chris@16
|
54 OutputIter result) {
|
Chris@16
|
55 for ( ; count > 0; --count) {
|
Chris@16
|
56 *result = *first;
|
Chris@16
|
57 ++first;
|
Chris@16
|
58 ++result;
|
Chris@16
|
59 }
|
Chris@16
|
60 return result;
|
Chris@16
|
61 }
|
Chris@16
|
62 #else // !1
|
Chris@16
|
63
|
Chris@16
|
64 template <class InputIter, class Size, class OutputIter>
|
Chris@16
|
65 OutputIter copy_n__(InputIter first, Size count,
|
Chris@16
|
66 OutputIter result,
|
Chris@16
|
67 std::input_iterator_tag) {
|
Chris@16
|
68 for ( ; count > 0; --count) {
|
Chris@16
|
69 *result = *first;
|
Chris@16
|
70 ++first;
|
Chris@16
|
71 ++result;
|
Chris@16
|
72 }
|
Chris@16
|
73 return result;
|
Chris@16
|
74 }
|
Chris@16
|
75
|
Chris@16
|
76 template <class RAIter, class Size, class OutputIter>
|
Chris@16
|
77 inline OutputIter
|
Chris@16
|
78 copy_n__(RAIter first, Size count,
|
Chris@16
|
79 OutputIter result,
|
Chris@16
|
80 std::random_access_iterator_tag) {
|
Chris@16
|
81 RAIter last = first + count;
|
Chris@16
|
82 return std::copy(first, last, result);
|
Chris@16
|
83 }
|
Chris@16
|
84
|
Chris@16
|
85 template <class InputIter, class Size, class OutputIter>
|
Chris@16
|
86 inline OutputIter
|
Chris@16
|
87 copy_n__(InputIter first, Size count, OutputIter result) {
|
Chris@16
|
88 typedef typename std::iterator_traits<InputIter>::iterator_category cat;
|
Chris@16
|
89 return copy_n__(first, count, result, cat());
|
Chris@16
|
90 }
|
Chris@16
|
91
|
Chris@16
|
92 template <class InputIter, class Size, class OutputIter>
|
Chris@16
|
93 inline OutputIter
|
Chris@16
|
94 copy_n(InputIter first, Size count, OutputIter result) {
|
Chris@16
|
95 return copy_n__(first, count, result);
|
Chris@16
|
96 }
|
Chris@16
|
97
|
Chris@16
|
98 #endif // 1
|
Chris@16
|
99 } // namespace multi_array
|
Chris@16
|
100 } // namespace detail
|
Chris@16
|
101 } // namespace boost
|
Chris@16
|
102
|
Chris@16
|
103 #endif // BOOST_ALGORITHM_RG071801_HPP
|