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