/usr/include/givaro/givarrayfixed.h is in libgivaro-dev 4.0.2-8ubuntu1.
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 | // ==========================================================================
// $Source: /var/lib/cvs/Givaro/src/kernel/bstruct/givarrayfixed.h,v $
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// Author: T. Gautier
// $Id: givarrayfixed.h,v 1.5 2011-02-02 16:23:55 briceboyer Exp $
// ==========================================================================
/*! @file givarrayfixed.h
* @ingroup bstruct
* @brief ArrayFixed of type T with fixed dimension.
*/
#ifndef __GIVARO_array_fixed_H
#define __GIVARO_array_fixed_H
#include <stddef.h> // size_t
#include "givaro/givaromm.h"
#include "givaro/giverror.h"
#include "givaro/givperf.h"
namespace Givaro {
//! ArrayFixed
template <class T, size_t SIZE>
class ArrayFixed
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GIVARO_PERF_INEHERIT(ArrayFixed,T)
#else
: public _perfArrayFixed<T>
#endif
{
T _data[SIZE]; // _data
public :
typedef int Indice_t;
typedef T Type_t;
typedef ArrayFixed<T,SIZE> Self_t;
typedef Type_t *Iterator_t;
typedef const Type_t *constIterator_t;
//-- Default cstor:
ArrayFixed () {};
//-- Recopy cstor : implicit
//-- Destructor: implicit
//-- Physical copy operator: reallocate dest of the same SIZE
// as src (if necessary) and apply GivaroCopyItem<Array<T>,T> on each Element.
// This class can be specialized. Return dest (i.e, *this).
Self_t& copy(const Self_t& src);
//-- Return the occuped SIZE of the array
size_t size() const { return SIZE; }
//-- Return the physical size of the array (capacity)
size_t phsize() const { return SIZE; }
//-- Return the base ptr to the array
Type_t* baseptr() { return _data; }
Type_t* const baseptr() const { return _data; }
//-- Access to the ith Element:
const T& operator[] (Indice_t i) const {
GIVARO_ASSERT((i >=0)&&(i<SIZE), "[Array<T>::[]]: index out of bounds.");
return _data[i];
}
T& operator[] (Indice_t i) {
GIVARO_ASSERT((i >=0)&&(i<SIZE), "[Array<T>::[]]: index out of bounds.");
return _data[i];
}
// -- Iterator
Iterator_t begin() { return _data; }
Iterator_t end() { return _data + SIZE; }
constIterator_t begin() const { return _data; }
constIterator_t end() const { return _data + SIZE; }
template<class UNARYOP>
void map( UNARYOP& opcode );
template<class UNARYOP>
void map( UNARYOP& opcode ) const;
protected : //--------------------- protected Internal representation
private:
//-- assignement operator cannot be herited.
Self_t& operator= (const Self_t& p) {};
};
//! Map opcode on all Elements less or requal that ith.
//! Terminal recursion, specialization
template<class T, class UNARYOP, size_t ith>
struct __giv_map_less_ith;
template<class T, class UNARYOP>
struct __giv_map_less_ith<T, UNARYOP, 0> {
inline void operator()( T* data, UNARYOP& opcode )
{ opcode(data[0]); }
};
template<class T, class UNARYOP, size_t ith>
struct __giv_map_less_ith<T, UNARYOP, ith> {
inline void operator()( T* data, UNARYOP& opcode )
{
opcode(data[ith]);
__giv_map_less_ith<T,UNARYOP,ith-1>()(data, opcode);
}
};
template<class T, class UNARYOP, size_t ith>
struct __giv_map_less_ith_const;
template<class T, class UNARYOP>
struct __giv_map_less_ith_const<T,UNARYOP,0> {
inline operator()( const T* data, UNARYOP& opcode )
{ opcode(data[0]); }
};
template<class T, class UNARYOP, size_t ith>
struct __giv_map_less_ith_const<T,UNARYOP,ith> {
inline void operator() ( const T* data, UNARYOP& opcode )
{ opcode(data[ith]);
__giv_map_less_ith<T,UNARYOP,ith-1>(data, opcode);
}
};
//! Specialization
template<class T, size_t SIZE>
template<class UNARYOP>
void ArrayFixed<T,SIZE>::map( UNARYOP& opcode )
{ __giv_map_less_ith<T,UNARYOP,SIZE>()(_data, opcode); }
//! Specialization
template<class T, size_t SIZE>
template<class UNARYOP>
void ArrayFixed<T,SIZE>::map( UNARYOP& opcode ) const
{ __giv_map_less_ith_const<T,UNARYOP,SIZE>()(_data, opcode); }
} // namespace Givaro
#endif // __GIVARO_array_fixed_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s:syntax=cpp.doxygen
|