Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parser
src
Teuchos_vector.hpp
1
#ifndef TEUCHOS_VECTOR_HPP
2
#define TEUCHOS_VECTOR_HPP
3
4
#include <vector>
5
#include <Teuchos_Assert.hpp>
6
7
namespace
Teuchos
{
8
9
/* just some wrappers over std::vector to let us
10
do all indexing with int */
11
12
template
<
typename
T>
13
inline
int
size(std::vector<T>
const
& v) {
14
return
int(v.size());
15
}
16
17
template
<
typename
T>
18
inline
typename
std::vector<T>::reference at(std::vector<T>& v,
int
i) {
19
TEUCHOS_DEBUG_ASSERT(0 <= i);
20
TEUCHOS_DEBUG_ASSERT(i <
int
(v.size()));
21
return
v[std::size_t(i)];
22
}
23
24
template
<
typename
T>
25
inline
typename
std::vector<T>::const_reference at(std::vector<T>
const
& v,
int
i) {
26
TEUCHOS_DEBUG_ASSERT(0 <= i);
27
TEUCHOS_DEBUG_ASSERT(i <
int
(v.size()));
28
return
v[std::size_t(i)];
29
}
30
31
template
<
typename
T>
32
inline
void
resize(std::vector<T>& v,
int
n) {
33
TEUCHOS_DEBUG_ASSERT(0 <= n);
34
v.resize(std::size_t(n));
35
}
36
37
template
<
typename
T>
38
inline
void
reserve(std::vector<T>& v,
int
n) {
39
TEUCHOS_DEBUG_ASSERT(0 <= n);
40
v.reserve(std::size_t(n));
41
}
42
43
template
<
typename
T>
44
inline
std::vector<T> make_vector(
int
n, T
const
& init_val = T()) {
45
return
std::vector<T>(std::size_t(n), init_val);
46
}
47
48
template
<
typename
T>
49
void
add_back(std::vector<T>& vector, T& value) {
50
using
std::swap;
51
vector.push_back(T());
52
swap(vector.back(), value);
53
}
54
55
}
56
57
#endif
58
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0