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