tudocomp
– The TU Dortmund Compression Framework
|
A view into a slice of memory. More...
#include <GenericConstView.hpp>
Public Types | |
using | value_type = typename Super::value_type |
using | reference = T & |
using | const_reference = typename Super::const_reference |
using | pointer = T * |
using | const_pointer = typename Super::const_pointer |
using | iterator = pointer |
using | const_iterator = typename Super::const_iterator |
using | reverse_iterator = std::reverse_iterator< 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 | |
GenericView () | |
Construct a empty View. More... | |
GenericView (T *data, size_t len) | |
Construct a View pointing at len elements starting from data More... | |
GenericView (const GenericView &other) | |
Construct a View as a copy of other More... | |
GenericView (std::vector< T > &other) | |
Construct a View pointing at the contents of a vector. More... | |
template<size_t N> | |
GenericView (std::array< uliteral_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... | |
iterator | begin () |
Begin of iterator. More... | |
const_iterator | end () const |
End of iterator. More... | |
iterator | end () |
End of iterator. More... | |
const_reverse_iterator | rbegin () const |
Begin of reverse iterator. More... | |
reverse_iterator | rbegin () |
Begin of reverse iterator. More... | |
const_reverse_iterator | rend () const |
End of reverse iterator. More... | |
reverse_iterator | rend () |
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... | |
reference | operator[] (size_type n) |
Access the element at pos More... | |
const_reference | at (size_type pos) const |
Access the element at pos More... | |
reference | at (size_type n) |
Access the element at pos More... | |
const_reference | front () const |
Access the first element. More... | |
reference | front () |
Access the first element. More... | |
const_reference | back () const |
Access the last element. More... | |
reference | back () |
Access the last element. More... | |
const value_type * | data () const noexcept |
The backing memory location. More... | |
value_type * | data () 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 (GenericView &other) |
Swap two Views. More... | |
void | clear () |
Sets the size to 0. More... | |
GenericView | substr (size_type pos, size_type len=npos) const |
Construct a new View that is a sub view into the current one. More... | |
GenericView | 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 | |
template<class U > | |
void | swap (GenericView< U > &lhs, GenericView< U > &rhs) |
A view into a slice of memory.
This is an abstraction around a 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 23 of file GenericConstView.hpp.
using tdc::GenericView< T >::const_iterator = typename Super::const_iterator |
Definition at line 43 of file GenericView.hpp.
using tdc::GenericView< T >::const_pointer = typename Super::const_pointer |
Definition at line 41 of file GenericView.hpp.
using tdc::GenericView< T >::const_reference = typename Super::const_reference |
Definition at line 39 of file GenericView.hpp.
using tdc::GenericView< T >::const_reverse_iterator = typename Super::const_reverse_iterator |
Definition at line 45 of file GenericView.hpp.
using tdc::GenericView< T >::difference_type = typename Super::difference_type |
Definition at line 46 of file GenericView.hpp.
using tdc::GenericView< T >::iterator = pointer |
Definition at line 42 of file GenericView.hpp.
using tdc::GenericView< T >::pointer = T* |
Definition at line 40 of file GenericView.hpp.
using tdc::GenericView< T >::reference = T& |
Definition at line 38 of file GenericView.hpp.
using tdc::GenericView< T >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 44 of file GenericView.hpp.
using tdc::GenericView< T >::size_type = typename Super::size_type |
Definition at line 47 of file GenericView.hpp.
using tdc::GenericView< T >::value_type = typename Super::value_type |
Definition at line 37 of file GenericView.hpp.
|
inline |
Construct a empty View.
Definition at line 57 of file GenericView.hpp.
|
inline |
Construct a View pointing at len
elements starting from data
Definition at line 61 of file GenericView.hpp.
|
inline |
Construct a View as a copy of other
Definition at line 65 of file GenericView.hpp.
|
inline |
Construct a View pointing at the contents of a vector.
Definition at line 69 of file GenericView.hpp.
|
inline |
Construct a View pointing at the contents of a array.
Definition at line 74 of file GenericView.hpp.
|
inline |
Access the element at pos
This method is always bounds checked
Definition at line 175 of file GenericView.hpp.
|
inline |
Access the element at pos
This method is always bounds checked
Definition at line 182 of file GenericView.hpp.
|
inline |
Access the last element.
Definition at line 199 of file GenericView.hpp.
|
inline |
Access the last element.
Definition at line 204 of file GenericView.hpp.
|
inline |
Begin of iterator.
Definition at line 83 of file GenericView.hpp.
|
inline |
Begin of iterator.
Definition at line 88 of file GenericView.hpp.
|
inline |
Begin of const iterator.
Definition at line 123 of file GenericView.hpp.
|
inline |
End of const iterator.
Definition at line 128 of file GenericView.hpp.
|
inline |
Sets the size to 0.
Definition at line 235 of file GenericView.hpp.
|
inline |
Begin of const reverse iterator.
Definition at line 133 of file GenericView.hpp.
|
inline |
End of const reverse iterator.
Definition at line 138 of file GenericView.hpp.
|
inlinenoexcept |
The backing memory location.
Definition at line 210 of file GenericView.hpp.
|
inlinenoexcept |
The backing memory location.
Definition at line 215 of file GenericView.hpp.
|
inline |
Returns true
if empty.
Definition at line 153 of file GenericView.hpp.
|
inline |
End of iterator.
Definition at line 93 of file GenericView.hpp.
|
inline |
End of iterator.
Definition at line 98 of file GenericView.hpp.
|
inline |
Returns true
if the View ends with the literal other
Definition at line 293 of file GenericView.hpp.
|
inline |
Returns true
if the View ends with the sequence of literals contained in other
.
Definition at line 299 of file GenericView.hpp.
|
inline |
Access the first element.
Definition at line 188 of file GenericView.hpp.
|
inline |
Access the first element.
Definition at line 193 of file GenericView.hpp.
|
inline |
Returns max size of the View. Always the same as size()
Definition at line 148 of file GenericView.hpp.
|
inline |
Construct a vector with the contents of this View.
Definition at line 78 of file GenericView.hpp.
|
inline |
Access the element at pos
This method is bounds checked in debug builds
Definition at line 160 of file GenericView.hpp.
|
inline |
Access the element at pos
This method is bounds checked in debug builds
Definition at line 167 of file GenericView.hpp.
|
inline |
Remove the last element from the View.
Definition at line 220 of file GenericView.hpp.
|
inline |
Remove the first element from the View.
Definition at line 225 of file GenericView.hpp.
|
inline |
Begin of reverse iterator.
Definition at line 103 of file GenericView.hpp.
|
inline |
Begin of reverse iterator.
Definition at line 108 of file GenericView.hpp.
|
inline |
Removes the first n
elements from the View.
Definition at line 272 of file GenericView.hpp.
|
inline |
Removes the last n
elements from the View.
Definition at line 277 of file GenericView.hpp.
|
inline |
End of reverse iterator.
Definition at line 113 of file GenericView.hpp.
|
inline |
End of reverse iterator.
Definition at line 118 of file GenericView.hpp.
|
inline |
Returns size of the View.
Definition at line 143 of file GenericView.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 267 of file GenericView.hpp.
|
inline |
Returns true
if the View starts with the literal other
Definition at line 282 of file GenericView.hpp.
|
inline |
Returns true
if the View starts with the sequence of literals contained in other
.
Definition at line 288 of file GenericView.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 252 of file GenericView.hpp.
|
inline |
Swap two Views.
Definition at line 230 of file GenericView.hpp.
|
friend |
|
static |
Sentinel value indicating a index at the end of the view.
Definition at line 52 of file GenericView.hpp.