~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/multi_array/algorithm.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

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