Kyopro Library
読み取り中…
検索中…
一致する文字列を見つけられません
offset_vector.hpp
[詳解]
1
#
include
"../../kyopro_library/template.hpp"
2
3
/// @file offset_vector.hpp
4
/// @brief 負の添字を取れる vector
5
template
<
typename
T>
6
struct
OffsetVector
:
vector
<
T
> {
7
int
offset
=0;
8
OffsetVector
()=
default
;
9
10
/// @brief 添字として区間 [lo, hi] の値を取れる配列を宣言する
11
/// @param init 初期値
12
OffsetVector
(
int
lo,
int
hi, T init) {
13
assert(lo<=hi);
14
this
->assign(hi-lo+1,init);
15
offset
=-lo;
16
}
17
18
T&
operator
[](
int
i) {
19
assert(i+
offset
>=0);
20
return
vector<T>::operator[](i+offset);
21
}
22
23
T
operator
[](
int
i)
const
{
24
assert(i+
offset
>=0);
25
return
vector<T>::operator[](i+offset);
26
}
27
};
OffsetVector
Definition
offset_vector.hpp:6
OffsetVector::offset
int offset
Definition
offset_vector.hpp:7
OffsetVector::operator[]
T operator[](int i) const
Definition
offset_vector.hpp:23
OffsetVector::OffsetVector
OffsetVector()=default
OffsetVector::OffsetVector
OffsetVector(int lo, int hi, T init)
添字として区間 [lo, hi] の値を取れる配列を宣言する
Definition
offset_vector.hpp:12
OffsetVector::operator[]
T & operator[](int i)
Definition
offset_vector.hpp:18
data_structure
offset_vector.hpp
構築:
1.13.2