/usr/include/dcmtk/ofstd/ofalgo.h is in libdcmtk2-dev 3.6.0-15.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | /*
*
* Copyright (C) 1997-2010, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: ofstd
*
* Author: Andreas Barth
*
* Purpose:
* Defines template algorithms for contaimer classes with
* interfaces similar to the C++ Standard
*
* Last Update: $Author: joergr $
* Update Date: $Date: 2010-10-14 13:15:49 $
* CVS/RCS Revision: $Revision: 1.6 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
*
*/
#ifndef OFITER_H
#define OFITER_H
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/ofstd/oftypes.h"
// Usage:
// Function_type OFForEach(InputIterator_type, Function_type, first, last ,f)
// Applies function f from type Function_type to the result of
// derferencing every iterator in the range [first, last) starting
// with first and proceeding to last -1 (first, last are of type
// InputIterator_type). Returns f.
//
// InputIterator_type OFFind(InputIterator_type, T_type, first, last, value)
// Returns the first Iterator i of type InputIterator_type in the range
// [first, last) for which *i == value (of type T_type). Returns last,
// if no such iterator is found
//
// InputIterator_type OFFindIf(InputIterator_type, Predicate_type,
// first, last, pred)
// Returns the first iterator i of type InputIterator_type in the range
// [first, last) for which pred(*i) != false. The function pred is of
// type Predicate_type. Returns last, if no such iterator is found
//
// ForwardIterator OFAdjacentFind(ForwardIterator_type, first, last)
// Returns the first iterator i of type ForwardIterator_type such
// that both i and i+1 are in the range [first, last) and *i == *(i+1)
// returns last, if no such iterator is found. i+1 means the successor
// of i.
//
// ForwardIterator OFAdjacentFindPred(ForwardIterator_type,
// BinaryPredicate_type,
// first, last, pred)
// Returns the first iterator i of type ForwardIterator_type such
// that both i and i+1 are in the range [first, last) and
// pred (*i, *(i+1)) != false.
// Returns last, if no such iterator is found. i+1 means the successor
// of i.
//
// Additional Remarks:
// In some template functions one template parameter is another function.
// Some compilers cannot determine automatically the type of template
// function parameters, so you must give them a hint casting
// the parameter function to the correct type (e.g. NeXT gcc 2.5.8)
#if defined(HAVE_STL) || defined(HAVE_STL_ALGORITHMS)
// It is possible to use the standard template library list class since the
// interface is nearly identical.
// Important: If you want to use the standard template library (STL), no
// variable within a namespace using a class of the STL shall have a name
// of one class of the STL
#include <algorithm>
#define OFForEach(InputIterator_type, Function_type, first, last, f) for_each((first), (last), (f))
#define OFFind(InputIterator_type, T_type, first, last, value) find((first), (last), (value))
#define OFFindIf(InputIterator_type, Predicate_type, first, last, pred) find_if((first), (last), (pred))
#define OFAdjacentFind(ForwardIterator_type, first, last) adjacent_find((first), (last))
#define OFAdjacentFindPred(ForwardIterator_type, BinaryPredicate_type, first, last, pred) adjacent_find((first), (last), (pred))
#else
#ifdef HAVE_FUNCTION_TEMPLATE
#define OFForEach(InputIterator_type, Function_type, first, last, f) OF_ForEach((first), (last), (f))
#define OFFind(InputIterator_type, T_type, first, last, value) OF_Find((first), (last), (value))
#define OFFindIf(InputIterator_type, Predicate_type, first, last, pred) OF_FindIf((first), (last), (pred))
#define OFAdjacentFind(ForwardIterator_type, first, last) OF_AdjacentFind((first), (last))
#define OFAdjacentFindPred(ForwardIterator_type, BinaryPredicate_type, first, last, pred) OF_AdjacentFind((first), (last), (pred))
#elif defined(HAVE_STATIC_TEMPLATE_METHOD)
#define OFForEach(InputIterator_type, Function_type, first, last, f) OF_ForEachClass<InputIterator_type, Function_type>::OF_ForEach((first), (last), (f))
#define OFFind(InputIterator_type, T_type, first, last, value) OF_FindClass<InputIterator_type, T_type>::OF_Find((first), (last), (value))
#define OFFindIf(InputIterator_type, Predicate_type, first, last, pred) OF_FindIfClass<InputIterator_type, Predicate_type>::OF_FindIf((first), (last), (pred))
#define OFAdjacentFind(ForwardIterator_type, first, last) OF_AdjacentFindClass<ForwardIterator_type, int>::OF_AdjacentFind((first), (last))
#define OFAdjacentFindPred(ForwardIterator_type, BinaryPredicate_type, first, last, pred) OF_AdjacentFindPredClass<ForwardIterator_type, BinaryPredicate_type>::OF_AdjacentFind((first), (last), (pred))
#else
#error Your C++ Compiler is not capable of compiling this code
#endif
template <class InputIterator, class Function>
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
class OF_ForEachClass
{
public:
static
#endif
Function OF_ForEach(InputIterator first, InputIterator last, Function f)
{
while (first != last)
{
f(*first);
++first;
}
return f;
}
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
};
#endif
template <class InputIterator, class T>
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
class OF_FindClass
{
public:
static
#endif
InputIterator OF_Find(InputIterator first, InputIterator last, const T & value)
{
while (first != last && *first != value) ++ first;
return first;
}
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
};
#endif
template <class InputIterator, class Predicate>
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
class OF_FindIfClass
{
public:
static
#endif
InputIterator OF_FindIf(InputIterator first, InputIterator last,
Predicate pred)
{
while (first != last && !pred(*first)) ++first;
return first;
}
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
};
#endif
template <class ForwardIterator>
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
class OF_AdjacentFindClass
{
public:
static
#endif
ForwardIterator OF_AdjacentFind(ForwardIterator first, ForwardIterator last)
{
if (first == last) return last;
ForwardIterator next(first);
while (++next != last)
{
if (*first == *next) return *first;
++first;
}
return last;
}
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
};
#endif
template <class ForwardIterator, class BinaryPredicate>
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
class OF_AdjacentFindPredClass
{
public:
static
#endif
ForwardIterator OF_AdjacentFind(ForwardIterator first, ForwardIterator last,
BinaryPredicate pred)
{
if (first == last) return last;
ForwardIterator next = first;
while(++next != last)
{
if (pred(*first, *last)) return first;
++first;
}
return last;
}
#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)
};
#endif
#endif
#endif
|