tudocomp
– The TU Dortmund Compression Framework
|
A const view into a slice of memory. More...
#include <GenericConstView.hpp>
Public Types | |
using | value_type = typename Super::value_type |
using | const_reference = typename Super::const_reference |
using | const_pointer = typename Super::const_pointer |
using | const_iterator = typename Super::const_iterator |
using | const_reverse_iterator = typename Super::const_reverse_iterator |
using | difference_type = typename Super::difference_type |
using | size_type = typename Super::size_type |
Public Member Functions | |
ConstGenericView () | |
Construct a empty View. More... | |
ConstGenericView (const T *data, size_t len) | |
Construct a View pointing at len elements starting from data More... | |
ConstGenericView (const ConstGenericView &other) | |
Construct a View as a copy of other More... | |
ConstGenericView (const GenericView< T > &other) | |
Construct a View as a copy of other More... | |
ConstGenericView (const std::vector< T > &other) | |
Construct a View pointing at the contents of a vector. More... | |
template<size_t N> | |
ConstGenericView (const std::array< T, N > &other) | |
Construct a View pointing at the contents of a array. More... | |
operator std::vector< T > () const | |
Construct a vector with the contents of this View. More... | |
const_iterator | begin () const |
Begin of iterator. More... | |
const_iterator | end () const |
End of iterator. More... | |
const_reverse_iterator | rbegin () const |
Begin of reverse iterator. More... | |
const_reverse_iterator | rend () const |
End of reverse iterator. More... | |
const_iterator | cbegin () const |
Begin of const iterator. More... | |
const_iterator | cend () const |
End of const iterator. More... | |
const_reverse_iterator | crbegin () const |
Begin of const reverse iterator. More... | |
const_reverse_iterator | crend () const |
End of const reverse iterator. More... | |
size_type | size () const |
Returns size of the View. More... | |
size_type | max_size () const |
Returns max size of the View. Always the same as size() More... | |
bool | empty () const |
Returns true if empty. More... | |
const_reference | operator[] (size_type pos) const |
Access the element at pos More... | |
const_reference | at (size_type pos) const |
Access the element at pos More... | |
const_reference | front () const |
Access the first element. More... | |
const_reference | back () const |
Access the last element. More... | |
const value_type * | data () const noexcept |
The backing memory location. More... | |
void | pop_back () |
Remove the last element from the View. More... | |
void | pop_front () |
Remove the first element from the View. More... | |
void | swap (ConstGenericView &other) |
Swap two Views. More... | |
void | clear () |
Sets the size to 0. More... | |
ConstGenericView | substr (size_type pos, size_type len=npos) const |
Construct a new View that is a sub view into the current one. More... | |
ConstGenericView | slice (size_type from, size_type to=npos) const |
Construct a new View that is a sub view into the current one. More... | |
void | remove_prefix (size_type n) |
Removes the first n elements from the View. More... | |
void | remove_suffix (size_type n) |
Removes the last n elements from the View. More... | |
bool | starts_with (const T &other) const |
Returns true if the View starts with the literal other More... | |
bool | starts_with (const ConstGenericView< T > &other) const |
Returns true if the View starts with the sequence of literals contained in other . More... | |
bool | ends_with (const T &other) const |
Returns true if the View ends with the literal other More... | |
bool | ends_with (const ConstGenericView< T > &other) const |
Returns true if the View ends with the sequence of literals contained in other . More... | |
Static Public Attributes | |
static const size_type | npos = Super::npos |
Sentinel value indicating a index at the end of the view. More... | |
Friends | |
class | GenericView< T > |
template<class U > | |
void | swap (ConstGenericView< U > &lhs, ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator== (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator!= (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator< (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator<= (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator> (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
template<typename U > | |
bool | operator>= (const ConstGenericView< U > &lhs, const ConstGenericView< U > &rhs) |
A const view into a slice of memory.
This is an abstraction around a const pointer to T
and a size, and represents N elements consecutive in memory.
Creating/Copying/Modifying a View will not copy any of the data it points at. Its API mostly mirrors that of a std::vector<T>
.
Definition at line 33 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::const_iterator = typename Super::const_iterator |
Definition at line 48 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::const_pointer = typename Super::const_pointer |
Definition at line 47 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::const_reference = typename Super::const_reference |
Definition at line 46 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::const_reverse_iterator = typename Super::const_reverse_iterator |
Definition at line 49 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::difference_type = typename Super::difference_type |
Definition at line 50 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::size_type = typename Super::size_type |
Definition at line 51 of file GenericConstView.hpp.
using tdc::ConstGenericView< T >::value_type = typename Super::value_type |
Definition at line 45 of file GenericConstView.hpp.
|
inline |
Construct a empty View.
Definition at line 57 of file GenericConstView.hpp.
|
inline |
Construct a View pointing at len
elements starting from data
Definition at line 61 of file GenericConstView.hpp.
|
inline |
Construct a View as a copy of other
Definition at line 65 of file GenericConstView.hpp.
|
inline |
Construct a View as a copy of other
Definition at line 69 of file GenericConstView.hpp.
|
inline |
Construct a View pointing at the contents of a vector.
Definition at line 73 of file GenericConstView.hpp.
|
inline |
Construct a View pointing at the contents of a array.
Definition at line 78 of file GenericConstView.hpp.
|
inline |
Access the element at pos
This method is always bounds checked
Definition at line 151 of file GenericConstView.hpp.
|
inline |
Access the last element.
Definition at line 161 of file GenericConstView.hpp.
|
inline |
Begin of iterator.
Definition at line 87 of file GenericConstView.hpp.
|
inline |
Begin of const iterator.
Definition at line 107 of file GenericConstView.hpp.
|
inline |
End of const iterator.
Definition at line 112 of file GenericConstView.hpp.
|
inline |
Sets the size to 0.
Definition at line 186 of file GenericConstView.hpp.
|
inline |
Begin of const reverse iterator.
Definition at line 117 of file GenericConstView.hpp.
|
inline |
End of const reverse iterator.
Definition at line 122 of file GenericConstView.hpp.
|
inlinenoexcept |
The backing memory location.
Definition at line 166 of file GenericConstView.hpp.
|
inline |
Returns true
if empty.
Definition at line 137 of file GenericConstView.hpp.
|
inline |
End of iterator.
Definition at line 92 of file GenericConstView.hpp.
|
inline |
Returns true
if the View ends with the literal other
Definition at line 244 of file GenericConstView.hpp.
|
inline |
Returns true
if the View ends with the sequence of literals contained in other
.
Definition at line 250 of file GenericConstView.hpp.
|
inline |
Access the first element.
Definition at line 156 of file GenericConstView.hpp.
|
inline |
Returns max size of the View. Always the same as size()
Definition at line 132 of file GenericConstView.hpp.
|
inline |
Construct a vector with the contents of this View.
Definition at line 82 of file GenericConstView.hpp.
|
inline |
Access the element at pos
This method is bounds checked in debug builds
Definition at line 144 of file GenericConstView.hpp.
|
inline |
Remove the last element from the View.
Definition at line 171 of file GenericConstView.hpp.
|
inline |
Remove the first element from the View.
Definition at line 176 of file GenericConstView.hpp.
|
inline |
Begin of reverse iterator.
Definition at line 97 of file GenericConstView.hpp.
|
inline |
Removes the first n
elements from the View.
Definition at line 223 of file GenericConstView.hpp.
|
inline |
Removes the last n
elements from the View.
Definition at line 228 of file GenericConstView.hpp.
|
inline |
End of reverse iterator.
Definition at line 102 of file GenericConstView.hpp.
|
inline |
Returns size of the View.
Definition at line 127 of file GenericConstView.hpp.
|
inline |
Construct a new View that is a sub view into the current one.
The returned view will be a "from-to" slice, and cover the bytes starting at from
and ending just before to
. T.slice(a,b) gives T[a..b-1]
Passing npos
to to
will create a slice until the end of the View
View("abcd").slice(1, 3) == View("bc")
Definition at line 218 of file GenericConstView.hpp.
|
inline |
Returns true
if the View starts with the literal other
Definition at line 233 of file GenericConstView.hpp.
|
inline |
Returns true
if the View starts with the sequence of literals contained in other
.
Definition at line 239 of file GenericConstView.hpp.
|
inline |
Construct a new View that is a sub view into the current one.
The returned view will be a "position-length" slice, and cover the bytes starting at pos
and ending at pos + len
.
Passing npos
to len
will create a slice until the end of the View
This method covers the same basic operation as slice()
, but mirrors the semantic of std::string::substr
.
View("abcd").substr(1, 2) == View("bc")
Definition at line 203 of file GenericConstView.hpp.
|
inline |
Swap two Views.
Definition at line 181 of file GenericConstView.hpp.
|
friend |
Definition at line 36 of file GenericConstView.hpp.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
static |
Sentinel value indicating a index at the end of the view.
Definition at line 54 of file GenericConstView.hpp.