numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
|
Class to save data in a sequence which can be extended even toward negative direction. More...
#include <num_collect/util/bidirectional_vector.h>
Public Types | |
using | container_type = Container |
Type of the internal container. | |
using | value_type = Value |
Type of values. | |
Public Member Functions | |
bidirectional_vector ()=default | |
Constructor. | |
bidirectional_vector (container_type container, index_type origin_index) | |
Constructor. | |
auto | at (index_type index) -> value_type & |
Access a value with checks. | |
auto | at (index_type index) const -> const value_type & |
Access a value with checks. | |
auto | container () const noexcept -> const container_type & |
Get the internal container. | |
auto | empty () const noexcept -> bool |
Check whether this object is empty. | |
auto | get_or_prepare (index_type index) -> value_type & |
Access a value preparing it if needed. | |
auto | max_index () const noexcept -> index_type |
Get the maximum index. | |
auto | min_index () const noexcept -> index_type |
Get the minimum index. (Equal to the index of the origin.) | |
void | move_position (index_type offset) |
Move the position of this object. | |
auto | operator[] (index_type index) -> value_type & |
Access a value without checks. | |
auto | operator[] (index_type index) const -> const value_type & |
Access a value without checks. | |
void | push_back (const value_type &value) |
Add a value to the end. | |
void | push_front (const value_type &value) |
Add a value to the beginning. | |
void | resize (index_type min_index, index_type max_index, const value_type &value=value_type()) |
Change the position of this object. | |
Private Member Functions | |
auto | container_index (index_type index) const -> std::size_t |
Calculate the index in the container with checks. | |
auto | is_safe_offset (index_type offset) const noexcept -> bool |
Check whether the given offset is safe to move. | |
void | prepare_for (index_type index) |
Prepare space for an index. | |
void | throw_out_of_range (index_type index) const |
Throw exception for indices out of range. | |
auto | unsafe_container_index (index_type index) const noexcept -> std::size_t |
Calculate the index in the container without checks. | |
Private Attributes | |
container_type | container_ {} |
Internal container. | |
index_type | origin_index_ {0} |
Index of origin. | |
Class to save data in a sequence which can be extended even toward negative direction.
This class generalizes std::vector
class. Indices can be positive integers, zero, or negative integers.
Value | Type of values. |
Container | Type of the internal container. (Assumed to be std::deque .) |
Definition at line 47 of file bidirectional_vector.h.
using num_collect::util::bidirectional_vector< Value, Container >::container_type = Container |
Type of the internal container.
Definition at line 53 of file bidirectional_vector.h.
using num_collect::util::bidirectional_vector< Value, Container >::value_type = Value |
Type of values.
Definition at line 50 of file bidirectional_vector.h.
|
inline |
Constructor.
[in] | container | Internal container. |
[in] | origin_index | Index of origin. |
Definition at line 66 of file bidirectional_vector.h.
|
inlinenodiscard |
Access a value with checks.
This version throws for indices out of range.
[in] | index | Index. |
Definition at line 125 of file bidirectional_vector.h.
|
inlinenodiscard |
Access a value with checks.
This version throws for indices out of range.
[in] | index | Index. |
Definition at line 113 of file bidirectional_vector.h.
|
inlinenodiscardnoexcept |
Get the internal container.
Definition at line 74 of file bidirectional_vector.h.
|
inlinenodiscardprivate |
Calculate the index in the container with checks.
[in] | index | Index for this object. |
Definition at line 250 of file bidirectional_vector.h.
|
inlinenodiscardnoexcept |
Check whether this object is empty.
Definition at line 83 of file bidirectional_vector.h.
|
inlinenodiscard |
Access a value preparing it if needed.
[in] | index | Index. |
Definition at line 159 of file bidirectional_vector.h.
|
inlinenodiscardprivatenoexcept |
Check whether the given offset is safe to move.
[in] | offset | Offset. |
Definition at line 317 of file bidirectional_vector.h.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Get the minimum index. (Equal to the index of the origin.)
Definition at line 92 of file bidirectional_vector.h.
|
inline |
Move the position of this object.
[in] | offset | Offset from the current position. |
Definition at line 232 of file bidirectional_vector.h.
|
inlinenodiscard |
Access a value without checks.
Access to indices out of range causes undefined behaviour.
[in] | index | Index. |
Definition at line 149 of file bidirectional_vector.h.
|
inlinenodiscard |
Access a value without checks.
Access to indices out of range causes undefined behaviour.
[in] | index | Index. |
Definition at line 137 of file bidirectional_vector.h.
|
inlineprivate |
Prepare space for an index.
[in] | index | Index. |
Definition at line 288 of file bidirectional_vector.h.
|
inline |
Add a value to the end.
[in] | value | Value. |
Definition at line 225 of file bidirectional_vector.h.
|
inline |
Add a value to the beginning.
[in] | value | Value. |
Definition at line 213 of file bidirectional_vector.h.
|
inline |
Change the position of this object.
[in] | min_index | Minimum index. |
[in] | max_index | Maximum index. |
[in] | value | Additional values. |
Definition at line 171 of file bidirectional_vector.h.
|
inlineprivate |
Throw exception for indices out of range.
[in] | index | Index. |
Definition at line 277 of file bidirectional_vector.h.
|
inlinenodiscardprivatenoexcept |
Calculate the index in the container without checks.
[in] | index | Index for this object. |
Definition at line 267 of file bidirectional_vector.h.
|
private |
Internal container.
Definition at line 239 of file bidirectional_vector.h.
|
private |
Index of origin.
Definition at line 242 of file bidirectional_vector.h.