chunkedseq
container library for large in-memory data sets
|
#include <chunkedseqbase.hpp>
Classes | |
class | DummyCachePrinter |
Public Types | |
using | iterator = Iterator< self_type, config_type > |
Container-configuration types | |
using | config_type = Configuration |
using | self_type = chunkedseqbase< config_type > |
using | size_type = typename config_type::size_type |
using | difference_type = typename config_type::difference_type |
using | allocator_type = typename config_type::item_allocator_type |
Item-specific types | |
using | value_type = typename config_type::value_type |
using | reference = value_type & |
using | const_reference = const value_type & |
using | pointer = value_type * |
using | const_pointer = const value_type * |
using | segment_type = typename config_type::segment_type |
Cached-measure-specific types | |
using | cache_type = chunk_cache_type |
using | measured_type = typename cache_type::measured_type |
using | algebra_type = typename cache_type::algebra_type |
using | measure_type = typename cache_type::measure_type |
Public Member Functions | |
chunkedseqbase (std::initializer_list< value_type > l) | |
Constructors | |
chunkedseqbase () | |
Empty container constructor. More... | |
chunkedseqbase (size_type n, const value_type &val) | |
Fill constructor. More... | |
chunkedseqbase (const self_type &other) | |
Copy constructor. More... | |
Capacity | |
bool | empty () const |
Test whether the container is empty. More... | |
size_type | size () const |
Returns size. More... | |
Item access | |
value_type | front () const |
Accesses last item. More... | |
value_type | back () const |
Accesses first item. More... | |
void | backn (value_type *dst, size_type nb) const |
Access last items. More... | |
void | frontn (value_type *dst, size_type nb) const |
Access first items. More... | |
template<class Consumer > | |
void | stream_backn (const Consumer &cons, size_type nb) const |
Consume last items. More... | |
template<class Consumer > | |
void | stream_frontn (const Consumer &cons, size_type nb) const |
Consume first items. More... | |
value_type | operator[] (size_type n) const |
Access item. More... | |
reference | operator[] (size_type n) |
Access item. More... | |
Modifiers | |
void | push_front (const value_type &x) |
Adds item at the beginning. More... | |
void | push_back (const value_type &x) |
Adds item at the end. More... | |
value_type | pop_front () |
Deletes first item. More... | |
value_type | pop_back () |
Deletes last item. More... | |
void | pushn_back (const_pointer src, size_type nb) |
Adds items at the end. More... | |
void | pushn_front (const_pointer src, size_type nb) |
Adds items at the beginning. More... | |
void | popn_front (size_type nb) |
Deletes first items. More... | |
void | popn_back (size_type nb) |
Deletes last items. More... | |
void | popn_back (value_type *dst, size_type nb) |
Deletes first items. More... | |
void | popn_front (value_type *dst, size_type nb) |
Deletes last items. More... | |
template<class Producer > | |
void | stream_pushn_back (const Producer &prod, size_type nb) |
Adds items at the end. More... | |
template<class Producer > | |
void | stream_pushn_front (const Producer &prod, size_type nb) |
Adds items at the beginning. More... | |
template<class Consumer , bool should_consume = true> | |
void | stream_popn_back (const Consumer &cons, size_type nb) |
Deletes last items. More... | |
template<class Consumer , bool should_consume = true> | |
void | stream_popn_front (const Consumer &cons, size_type nb) |
Deletes first items. More... | |
void | concat (self_type &other) |
Merges with content of another container. More... | |
template<class Pred > | |
bool | split (const Pred &p, reference middle_item, self_type &other) |
template<class Pred > | |
void | split (const Pred &p, self_type &other) |
void | split (size_type i, self_type &other) |
Split by index. More... | |
void | split (iterator position, self_type &other) |
Split by iterator. More... | |
void | split_approximate (self_type &other) |
iterator | insert (iterator position, const value_type &val) |
Inserts items. More... | |
iterator | erase (iterator first, iterator last) |
Erases items. More... | |
void | clear () |
Clears items. More... | |
void | swap (self_type &other) |
Swaps content. More... | |
Cached measurement | |
measured_type | get_cached () const |
Returns cached measurement. More... | |
measure_type | get_measure () const |
Returns measurement operator. More... | |
void | set_measure (measure_type meas) |
Sets measurement operator. More... | |
void | copy_measure_to (self_type &other) |
Copies the measurement operator. More... | |
Debugging routines | |
template<class ItemPrinter > | |
void | print_chunk (const chunk_type &c) const |
template<class ItemPrinter , class CachePrinter = DummyCachePrinter> | |
void | print () const |
void | check_size () const |
void | check () const |
template<class Add_edge , class Process_chunk > | |
void | reveal_internal_structure (const Add_edge &add_edge, const Process_chunk &process_chunk) const |
Public Attributes | |
friend | iterator |
Protected Types | |
using | chunk_type = typename Configuration::chunk_type |
using | chunk_search_type = typename Configuration::chunk_search_type |
using | chunk_cache_type = typename Configuration::chunk_cache_type |
using | chunk_measured_type = typename chunk_cache_type::measured_type |
using | chunk_algebra_type = typename chunk_cache_type::algebra_type |
using | chunk_measure_type = typename chunk_cache_type::measure_type |
using | chunk_pointer = chunk_type * |
using | middle_type = typename Configuration::middle_type |
using | middle_cache_type = typename Configuration::middle_cache_type |
using | middle_measured_type = typename middle_cache_type::measured_type |
using | middle_algebra_type = typename middle_cache_type::algebra_type |
using | middle_measure_type = typename middle_cache_type::measure_type |
using | size_access = typename Configuration::size_access |
using | const_self_pointer_type = const chunkedseqbase< Configuration > * |
Static Protected Attributes | |
static constexpr int | chunk_capacity = Configuration::chunk_capacity |
Friends | |
void | extras::split_by_index (self_type &c, size_type i, self_type &other) |
Iterators | |
iterator | begin () const |
Returns iterator to beginning. More... | |
iterator | end () const |
Returns iterator to end. More... | |
template<class Body > | |
void | for_each (const Body &f) const |
Visits every item in the container. More... | |
template<class Body > | |
void | for_each (iterator beg, iterator end, const Body &f) const |
Visits every item in a specified range. More... | |
template<class Body > | |
void | for_each_segment (const Body &f) const |
Visits every segment of items in the container. More... | |
template<class Body > | |
static void | for_each_segment (iterator begin, iterator end, const Body &f) |
Visits every segment of items in a specified range. More... | |
Configuration | type of the class from which to access configuration parameters for the container |
Iterator | type of the class to represent the iterator |
later: explain the following preconditions Assume "Chunk" to implement fixed-capacity circular buffers. Assume "Topchunk_capacity >= 2" and "Recchunk_capacity >= 2". Assume TopItem to have a trivial destructor.
later: study in detail the memory usage behavior of chunkedseq
Definition at line 59 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::algebra_type = typename cache_type::algebra_type |
Definition at line 112 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::allocator_type = typename config_type::item_allocator_type |
Definition at line 91 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::cache_type = chunk_cache_type |
Definition at line 110 of file chunkedseqbase.hpp.
|
protected |
Definition at line 66 of file chunkedseqbase.hpp.
|
protected |
Definition at line 64 of file chunkedseqbase.hpp.
|
protected |
Definition at line 67 of file chunkedseqbase.hpp.
|
protected |
Definition at line 65 of file chunkedseqbase.hpp.
|
protected |
Definition at line 68 of file chunkedseqbase.hpp.
|
protected |
Definition at line 63 of file chunkedseqbase.hpp.
|
protected |
Definition at line 62 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::config_type = Configuration |
Definition at line 87 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::const_pointer = const value_type* |
Definition at line 102 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::const_reference = const value_type& |
Definition at line 100 of file chunkedseqbase.hpp.
|
protected |
Definition at line 77 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::difference_type = typename config_type::difference_type |
Definition at line 90 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::iterator = Iterator<self_type, config_type> |
Definition at line 116 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::measure_type = typename cache_type::measure_type |
Definition at line 113 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::measured_type = typename cache_type::measured_type |
Definition at line 111 of file chunkedseqbase.hpp.
|
protected |
Definition at line 73 of file chunkedseqbase.hpp.
|
protected |
Definition at line 71 of file chunkedseqbase.hpp.
|
protected |
Definition at line 74 of file chunkedseqbase.hpp.
|
protected |
Definition at line 72 of file chunkedseqbase.hpp.
|
protected |
Definition at line 70 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::pointer = value_type* |
Definition at line 101 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::reference = value_type& |
Definition at line 99 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::segment_type = typename config_type::segment_type |
Definition at line 103 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::self_type = chunkedseqbase<config_type> |
Definition at line 88 of file chunkedseqbase.hpp.
|
protected |
Definition at line 75 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::size_type = typename config_type::size_type |
Definition at line 89 of file chunkedseqbase.hpp.
using pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::value_type = typename config_type::value_type |
Definition at line 98 of file chunkedseqbase.hpp.
|
inline |
Constructs an empty container, with no items.
Constant
Definition at line 485 of file chunkedseqbase.hpp.
|
inline |
Constructs an empty container, with nb
items. Each item is a copy of val
.
nb | Number of items to put in the container |
val | Value to replicate |
Linear in nb
.
Definition at line 502 of file chunkedseqbase.hpp.
|
inline |
Constructs a container with a copy of each of the elements in other
, in the same order.
other | Container from which to copy. |
Linear in the resulting container size.
Definition at line 524 of file chunkedseqbase.hpp.
|
inline |
Definition at line 536 of file chunkedseqbase.hpp.
|
inline |
Returns a reference to the first item in the container.
Calling this method on an empty
container causes undefined behavior.
Amortized constant time (worst case logarithmic time).
Definition at line 632 of file chunkedseqbase.hpp.
|
inline |
Copies the last nb
items from the container to the cells in the array dst
.
Calling this method when size() < nb
causes undefined behavior.
Linear in the number of items being copied (i.e., nb
).
Definition at line 657 of file chunkedseqbase.hpp.
|
inline |
Returns an iterator pointing to the first element in the container.
Notice that, unlike member front(), which returns a reference to the first element, this function returns a random access iterator pointing to it.
If the container is empty, the returned iterator value shall not be dereferenced.
Logarithmic time.
Definition at line 1428 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1669 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1652 of file chunkedseqbase.hpp.
|
inline |
Removes all items from the container (which are destroyed), leaving the container with a size of 0.
Linear time (destructions).
Definition at line 1366 of file chunkedseqbase.hpp.
|
inline |
Removes all items from other
, effectively reducing its size to zero.
Adds items removed from other
to the back of this container, after its current last item.
other | Container from which to take items. |
Logarithmic in the size of the smallest of the two containers.
Definition at line 1212 of file chunkedseqbase.hpp.
|
inline |
|
inline |
Returns whether the container is empty ( i.e. whether its size is 0).
Constant time.
Definition at line 557 of file chunkedseqbase.hpp.
|
inline |
Returns an iterator referring to the past-the-end element in the container.
The past-the-end element is the theoretical element that would follow the last element in the vector. It does not point to any element, and thus shall not be dereferenced.
Because the ranges used by functions of the standard library do not include the element pointed by their closing iterator, this function is often used in combination with begin() to specify a range including all the elements in the container.
If the container is empty, this function returns the same as begin().
Logarithmic time.
Definition at line 1457 of file chunkedseqbase.hpp.
|
inline |
Removes from the container either a single item (position
) or a range of items ([first,last)
).
This effectively reduces the container size by the number of elements removed, which are destroyed.
Linear in the number of items erased (destructions) and logarithmic in the number of items in the size of the sequence.
first | Pointer to the first item to erase. |
last | Pointer to the position one past the last item to erase. |
Definition at line 1352 of file chunkedseqbase.hpp.
|
inline |
Applies a given function f
to each item in the sequence in the left-to-right order of the sequence.
f | Function to apply to each item. The type of this function must be std::function<void(value_type)> . |
Linear in the size of the container.
Definition at line 1475 of file chunkedseqbase.hpp.
|
inline |
Applies a given function f
to each item in the range specified by [beg,end)
.
The function is applied in left-to-right order.
f | Function to apply to each item. The type of this function must be std::function<void(value_type)> . |
beg | Pointer to the first item to visit |
end | Pointer to the item one past the last item to visit |
Linear in end-beg
.
Definition at line 1503 of file chunkedseqbase.hpp.
|
inline |
Applies a given function f
to each segment in the container.
See Segments for a description of the segment type.
f | Function to apply to each segment. The type of this function must be std::function<void(segment_type)> . |
Linear in the number of segments in the container (assuming that f
visits each segment in unit time).
Definition at line 1523 of file chunkedseqbase.hpp.
|
inlinestatic |
Applies a given function f
to each segment in the range defined by [beg,end)
.
See Segments for a description of the segment type.
f | Function to apply to the segments. The type of this function must be std::function<void(segment_type)> . |
beg | Pointer to the first item to visit |
end | Pointer to the item one past the last item to visit |
Linear in the number of segments in the given range (assuming that f
visits each segment in unit time).
Definition at line 1552 of file chunkedseqbase.hpp.
|
inline |
Returns a reference to the last item in the container.
Calling this method on an empty
container causes undefined behavior.
Amortized constant time (worst case logarithmic time).
Definition at line 604 of file chunkedseqbase.hpp.
|
inline |
Copies the first nb
items from the container to the cells in the array dst
.
Calling this method when size() < nb
causes undefined behavior.
Linear in the number of items being copied (i.e., nb
).
Definition at line 674 of file chunkedseqbase.hpp.
|
inline |
Constant time.
Definition at line 1570 of file chunkedseqbase.hpp.
|
inline |
|
inline |
The container is extended by inserting new items before the item at the specified position.
This effectively increates the container size by the amount of items inserted.
Insertions at the front or back are slightly more efficient than on other positions.
The parameters determine how many elements are inserted and to which values they are initialized.
position | Position in the container where the new items are inserted |
val | Value to be copied (or moved) to the inserted items |
Logarithmic time.
Definition at line 1329 of file chunkedseqbase.hpp.
|
inline |
Returns a copy of the element at position n
in the vector container.
Position | of an item in the container. Notice that the first item has a position of 0 (not 1). Member type size_type is an unsigned integral type. |
Logarithmic time.
Definition at line 743 of file chunkedseqbase.hpp.
|
inline |
Returns a reference to the element at position n
in the vector container.
Position | of an item in the container. Notice that the first item has a position of 0 (not 1). Member type size_type is an unsigned integral type. |
Logarithmic time.
Definition at line 768 of file chunkedseqbase.hpp.
|
inline |
Removes the last item in the container, effectively reducing the container size by one.
Calling this method destroys the removed item.
Calling this method on an empty
container causes undefined behavior.
Amortized constant (worst case logarithmic).
Definition at line 882 of file chunkedseqbase.hpp.
|
inline |
Removes the first item in the container, effectively reducing the container size by one.
Calling this method destroys the removed item.
Calling this method on an empty
container causes undefined behavior.
Amortized constant (worst case logarithmic).
Definition at line 846 of file chunkedseqbase.hpp.
|
inline |
Removes the last items in the container, effectively reducing the container size by one.
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
destination | Array to which the removed values are to be copied (or moved). |
nb | Number of items to remove. |
Definition at line 976 of file chunkedseqbase.hpp.
|
inline |
Removes the first items in the container, effectively reducing the container size by nb
.
Copies the removed items to the array destination
.
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
destination | Array to which the removed values are to be copied (or moved). |
nb | Number of items to remove. |
Definition at line 1001 of file chunkedseqbase.hpp.
|
inline |
Removes the first items in the container, effectively reducing the container size by nb
.
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
nb | Number of items to remove. |
Definition at line 953 of file chunkedseqbase.hpp.
|
inline |
Removes the last items in the container, effectively reducing the container size by one.
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
destination | Array to which the removed values are to be copied (or moved). |
nb | Number of items to remove. |
Definition at line 1023 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1635 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1622 of file chunkedseqbase.hpp.
|
inline |
Adds a new item to the back of the container, after its current last item. The content of x
is copied (or moved) to the new item.
x | Value to be copied (or moved) to the new item. |
Amortized constant (worst case logarithmic).
Definition at line 818 of file chunkedseqbase.hpp.
|
inline |
Adds a new item to the front of the container, before its current first item. The content of x
is copied (or moved) to the new item.
x | Value to be copied (or moved) to the new item. |
Amortized constant (worst case logarithmic).
Definition at line 795 of file chunkedseqbase.hpp.
|
inline |
Adds new items from a given array to the back of the container, after its current last item. The content of items
is copied (or moved) to the new positions in the container.
items | Values to be copied (or moved) to the container. |
nb | Number of items to be inserted. |
Linear in number of inserted items.
Definition at line 915 of file chunkedseqbase.hpp.
|
inline |
Adds new items to the front of the container, before its current first item. The content of items
is copied (or moved) to the new positions in the container.
items | Values to be copied (or moved) to the container. |
nb | Number of items to be inserted. |
Linear in number of inserted items.
Definition at line 933 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1690 of file chunkedseqbase.hpp.
|
inline |
|
inline |
Returns the number of items in the container.
Constant time.
Definition at line 571 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1249 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1261 of file chunkedseqbase.hpp.
|
inline |
The container is erased after and including the item at (zero-based) index i
.
The erased items are moved to the other
container.
other
container is empty. i >= 0
i < size()
Definition at line 1279 of file chunkedseqbase.hpp.
|
inline |
The container is erased after and including the item at the specified position
.
The erased items are moved to the other
container.
other
container is empty. Definition at line 1293 of file chunkedseqbase.hpp.
|
inline |
Definition at line 1297 of file chunkedseqbase.hpp.
|
inline |
Streams the first nb
items from the container to the client-supplied function cons
.
Let our container be c = [c_0, c_1, ..., c_n]
. Then, the call stream_backn(cons, nb)
performs:
for (size_type i = nb-1; i < n+1; i++) cons(c_i);
Calling this method when size() < nb
causes undefined behavior.
Linear in the number of items being copied (i.e., nb
).
Definition at line 698 of file chunkedseqbase.hpp.
|
inline |
Streams the first nb
items from the container to the client-supplied function cons
.
Let our container be c = [c_0, c_1, ..., c_n]
. Then, the call stream_backn(cons, nb)
performs:
for (size_type i = 0; i < nb; i++) cons(c_i);
Calling this method when size() < nb
causes undefined behavior.
Linear in the number of items being copied (i.e., nb
).
Definition at line 722 of file chunkedseqbase.hpp.
|
inline |
Removes the last items in the container, effectively reducing the container size by nb
.
Let our container be c = [c_0, c_1, ..., c_n]
. Then, the call stream_backn(cons, nb)
performs:
for (size_type i = nb-1; i < n+1; i++) cons(c_i);
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
cons | Function to receive items being removed from the container. |
nb | Number of items to remove. |
Definition at line 1144 of file chunkedseqbase.hpp.
|
inline |
Removes the first items in the container, effectively reducing the container size by nb
.
Let our container be c = [c_0, c_1, ..., c_n]
. Then, the call stream_backn(cons, nb)
performs:
for (size_type i = 0; i < nb; i++) cons(c_i);
Calling this method destroys the removed items.
The behavior is undefined if nb > size()
.
Linear in number of items to be removed.
cons | Function to receive items being removed from the container. |
nb | Number of items to remove. |
Definition at line 1183 of file chunkedseqbase.hpp.
|
inline |
Adds new items from a given array to the back of the container, after its current last item. The content is generated by applications of the client-supplied function body
. The applications initialize the cells in the container in place.
For a container a
, new content is generated by applying body(0, a[0]); body(1, a[1]); ... body(n-1, a[n-1]); where n
is the size of the container.
Type | of the loop body class. This class must implement the interface defined by For-each loops . |
body | function to generate the contents |
nb | Number of items to be inserted. |
Linear in number of inserted items.
Definition at line 1049 of file chunkedseqbase.hpp.
|
inline |
Adds new items to the front of the container, before its current first item. The content is generated by applications of the client-supplied function body
. The applications initialize the cells in the container in place.
For a container a
, new content is generated by applying body(0, a[0]); body(1, a[1]); ... body(n-1, a[n-1]); where n
is the size of the container.
Type | of the loop body class. This class must implement the interface defined by For-each loops . |
body | function to generate the contents |
nb | Number of items to be inserted. |
Linear in number of inserted items.
Definition at line 1095 of file chunkedseqbase.hpp.
|
inline |
Exchanges the content of the container by the content of x
, which is another container of the same type. Sizes may differ.
After the call to this member function, the items in this container are those which were in x
before the call, and the elements of x
are those which were in this.
Constant time.
x | Another container container of the same type (i.e., instantiated with the same template parameters) whose content is swapped with that of this container. |
Definition at line 1390 of file chunkedseqbase.hpp.
|
friend |
|
staticprotected |
Definition at line 79 of file chunkedseqbase.hpp.
friend pasl::data::chunkedseq::chunkedseqbase< Configuration, Iterator >::iterator |
Definition at line 117 of file chunkedseqbase.hpp.