APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
extendedvector.h
Go to the documentation of this file.
1//
2// APFEL++ 2017
3//
4// Author: Valerio Bertone: valerio.bertone@cern.ch
5//
6
7#pragma once
8
9#include <vector>
10
11namespace apfel
12{
16 template<class T>
18 {
19 public:
26 ExtendedVector(int const& size = 0, T const& value = 0, int const& imin = 0): _imin(imin), _vector(size, value) {}
27
34 T& operator [] (int const& index) { return _vector[index - _imin]; }
35
42 const T& operator [] (int const& index) const { return _vector[index - _imin]; }
43
48 int min() const { return _imin; };
49
54 int max() const { return _vector.size() + _imin; };
55
59 size_t size() const { return _vector.size(); }
60
67 void resize(int const& size, T const& value = 0, int const& imin = 0) { _imin = imin; _vector.resize(size, value); }
68
72 typename std::vector<T>::iterator begin() { return _vector.begin(); }
73
77 typename std::vector<T>::const_iterator begin() const { return _vector.begin(); }
78
82 typename std::vector<T>::iterator end() { return _vector.end(); }
83
87 typename std::vector<T>::const_iterator end() const { return _vector.end(); }
88
89 private:
90 int _imin;
91 std::vector<T> _vector;
92 };
93}
Class that extends vectors to negative indices.
Definition extendedvector.h:18
std::vector< T >::const_iterator begin() const
Constant begin iterator.
Definition extendedvector.h:77
int max() const
Returns the upper bound.
Definition extendedvector.h:54
void resize(int const &size, T const &value=0, int const &imin=0)
Resizes the continer.
Definition extendedvector.h:67
std::vector< T >::const_iterator end() const
Constant end iterator.
Definition extendedvector.h:87
std::vector< T >::iterator begin()
Non-constant begin iterator.
Definition extendedvector.h:72
int _imin
The lower bound.
Definition extendedvector.h:90
std::vector< T > _vector
The container.
Definition extendedvector.h:91
ExtendedVector(int const &size=0, T const &value=0, int const &imin=0)
The ExtendedVector constructor.
Definition extendedvector.h:26
T & operator[](int const &index)
Returns the value at the possibly negative given index.
Definition extendedvector.h:34
std::vector< T >::iterator end()
Non-constant end iterator.
Definition extendedvector.h:82
size_t size() const
Returns the size of the vector.
Definition extendedvector.h:59
int min() const
Returns the lower bound.
Definition extendedvector.h:48
Namespace for all APFEL++ functions and classes.
Definition alphaqcd.h:14