FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Index.hpp
1#ifndef vector_Index_HPP
2#define vector_Index_HPP "Created 21.05.2006 12:12:12 by werner"
3
4#include <sys/types.h>
5#include <stdint.h>
6
7namespace Fiber
8{
9
10template <int PtrSize> struct IndexTypeConfig;
11
12template <> struct IndexTypeConfig<8> { typedef uint64_t index_t; };
13template <> struct IndexTypeConfig<4> { typedef uint32_t index_t; };
14
22typedef IndexTypeConfig<sizeof(void*)>::index_t index_t;
23
30constexpr inline int log2(index_t arg)
31{
32int loop = 0;
33 for (loop = 0; arg != 0; loop++, arg >>= 1)
34 ;
35
36 return loop;
37}
38
44{
45 v--;
46 v |= v >> 1;
47 v |= v >> 2;
48 v |= v >> 4;
49 v |= v >> 8;
50 v |= v >> 16;
51 v++;
52 return v;
53}
54
55constexpr inline index_t clamp(index_t value, index_t range)
56{
57 if (value>range) return range;
58 return value;
59}
60
61constexpr inline index_t clamp_m1(index_t value, index_t range)
62{
63 if (value>=range) return range-1;
64 return value;
65}
66
67constexpr inline index_t clamp(index_t low_range, index_t value, index_t high_range)
68{
69 if (value < low_range ) return low_range;
70 if (value > high_range) return high_range;
71
72 return value;
73}
74
75} /* namespace Fiber */
76
77#endif /* vector_Index_HPP */
constexpr const _Tp & clamp(const _Tp &__val, const _Tp &__lo, const _Tp &__hi)
__gnu_cxx::__promote< _Tp >::__type arg(_Tp __x)
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
constexpr index_t RoundUpToNextHighestPowerOf2(index_t v)
Align a value to the next fitting power of 2.
Definition Index.hpp:43
constexpr int log2(index_t arg)
Compute the logarithm to the basis of two from the given index.
Definition Index.hpp:30
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
Definition Index.hpp:10