sparrow 2.5.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
sparrow::buffer< T > Class Template Reference

Object that owns a piece of contiguous memory. More...

#include <buffer.hpp>

Inheritance diagram for sparrow::buffer< T >:
[legend]
Collaboration diagram for sparrow::buffer< T >:
[legend]

Public Types

using allocator_type = typename base_type::allocator_type
using default_allocator = xsimd::aligned_allocator<T>
using value_type = T
using reference = value_type&
using const_reference = const value_type&
using pointer = typename alloc_traits::pointer
using const_pointer = typename alloc_traits::const_pointer
using size_type = typename alloc_traits::size_type
using difference_type = typename alloc_traits::difference_type
using iterator = pointer_iterator<pointer>
using const_iterator = pointer_iterator<const_pointer>
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Member Functions

 buffer ()=default
template<class A>
requires (not std::same_as<A, buffer<T>> and allocator<A>)
constexpr buffer (const A &a)
template<allocator A>
constexpr buffer (size_type n, const A &a)
template<allocator A>
requires ( std::is_trivially_default_constructible_v<T> && std::is_trivially_destructible_v<T> )
constexpr buffer (size_type n, uninitialized_t, const A &a)
 Constructs a buffer whose elements are not initialized.
template<allocator A>
constexpr buffer (size_type n, const value_type &v, const A &a)
template<allocator A>
constexpr buffer (pointer p, size_type n, const A &a)
template<allocator A>
constexpr buffer (std::initializer_list< value_type > init, const A &a)
template<class It, allocator A>
constexpr buffer (It first, It last, const A &a)
template<std::ranges::input_range Range, allocator A>
requires (std::same_as<std::ranges::range_value_t<Range>, T> && !is_buffer_view<Range>)
constexpr buffer (const Range &range, const A &a)
 ~buffer ()
constexpr buffer (const buffer &rhs)
template<allocator A>
constexpr buffer (const buffer &rhs, const A &a)
constexpr buffer (buffer &&rhs) noexcept=default
template<allocator A>
constexpr buffer (buffer &&rhs, const A &a)
constexpr bufferoperator= (const buffer &rhs)
constexpr bufferoperator= (buffer &&rhs)
constexpr bufferoperator= (std::initializer_list< value_type > init)
constexpr reference operator[] (size_type i)
constexpr const_reference operator[] (size_type i) const
constexpr reference front ()
constexpr const_reference front () const
constexpr reference back ()
constexpr const_reference back () const
template<class U = T>
constexpr U * data () noexcept
template<class U = T>
constexpr const U * data () const noexcept
constexpr iterator begin () noexcept
constexpr iterator end () noexcept
constexpr const_iterator begin () const noexcept
constexpr const_iterator end () const noexcept
constexpr const_iterator cbegin () const noexcept
constexpr const_iterator cend () const noexcept
constexpr reverse_iterator rbegin () noexcept
constexpr reverse_iterator rend () noexcept
constexpr const_reverse_iterator rbegin () const noexcept
constexpr const_reverse_iterator rend () const noexcept
constexpr const_reverse_iterator crbegin () const noexcept
constexpr const_reverse_iterator crend () const noexcept
constexpr bool empty () const noexcept
constexpr size_type capacity () const noexcept
constexpr size_type size () const noexcept
constexpr size_type max_size () const noexcept
constexpr void reserve (size_type new_cap)
constexpr void shrink_to_fit ()
constexpr void clear ()
constexpr iterator insert (const_iterator pos, const T &value)
constexpr iterator insert (const_iterator pos, T &&value)
constexpr iterator insert (const_iterator pos, size_type count, const T &value)
template<mpl::iterator_of_type< T > InputIt>
constexpr iterator insert (const_iterator pos, InputIt first, InputIt last)
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
constexpr iterator insert (const_iterator pos, R &&range)
constexpr iterator insert (const_iterator pos, std::initializer_list< T > ilist)
template<class... Args>
constexpr iterator emplace (const_iterator pos, Args &&... args)
constexpr iterator erase (const_iterator pos)
constexpr iterator erase (const_iterator first, const_iterator last)
constexpr void push_back (const T &value)
constexpr void push_back (T &&value)
constexpr void pop_back ()
constexpr void resize (size_type new_size)
constexpr void resize (size_type new_size, const value_type &value)
constexpr void swap (buffer &rhs) noexcept
template<mpl::iterator_of_type< T > InputIt>
constexpr auto insert (const_iterator pos, InputIt first, InputIt last) -> iterator
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
constexpr auto insert (const_iterator pos, R &&range) -> iterator
template<class It>
constexpr auto allocate_and_copy (size_type n, It first, It last) -> pointer
template<class It>
constexpr auto copy_initialize (It first, It last, pointer begin, allocator_type &a) -> pointer
constexpr allocator_typeget_allocator () noexcept
constexpr const allocator_typeget_allocator () const noexcept

Detailed Description

template<class T>
class sparrow::buffer< T >

Object that owns a piece of contiguous memory.

This class provides an API similar to std::vector, with two main differences:

  • it is not templated by the allocator type, but makes use of any_allocator which type-erases it.
  • it can acquire ownership of an already allocated raw buffer.

Definition at line 141 of file buffer.hpp.

Member Typedef Documentation

◆ allocator_type

template<class T>
using sparrow::buffer< T >::allocator_type = typename base_type::allocator_type

Definition at line 154 of file buffer.hpp.

◆ const_iterator

template<class T>
using sparrow::buffer< T >::const_iterator = pointer_iterator<const_pointer>

Definition at line 164 of file buffer.hpp.

◆ const_pointer

template<class T>
using sparrow::buffer< T >::const_pointer = typename alloc_traits::const_pointer

Definition at line 160 of file buffer.hpp.

◆ const_reference

template<class T>
using sparrow::buffer< T >::const_reference = const value_type&

Definition at line 158 of file buffer.hpp.

◆ const_reverse_iterator

template<class T>
using sparrow::buffer< T >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 166 of file buffer.hpp.

◆ default_allocator

template<class T>
using sparrow::buffer< T >::default_allocator = xsimd::aligned_allocator<T>

◆ difference_type

template<class T>
using sparrow::buffer< T >::difference_type = typename alloc_traits::difference_type

Definition at line 162 of file buffer.hpp.

◆ iterator

template<class T>
using sparrow::buffer< T >::iterator = pointer_iterator<pointer>

Definition at line 163 of file buffer.hpp.

◆ pointer

template<class T>
using sparrow::buffer< T >::pointer = typename alloc_traits::pointer

Definition at line 159 of file buffer.hpp.

◆ reference

template<class T>
using sparrow::buffer< T >::reference = value_type&

Definition at line 157 of file buffer.hpp.

◆ reverse_iterator

template<class T>
using sparrow::buffer< T >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 165 of file buffer.hpp.

◆ size_type

template<class T>
using sparrow::buffer< T >::size_type = typename alloc_traits::size_type

Definition at line 161 of file buffer.hpp.

◆ value_type

template<class T>
using sparrow::buffer< T >::value_type = T

Definition at line 156 of file buffer.hpp.

Constructor & Destructor Documentation

◆ buffer() [1/13]

template<class T>
sparrow::buffer< T >::buffer ( )
default
Here is the caller graph for this function:

◆ buffer() [2/13]

template<class T>
template<class A>
requires (not std::same_as<A, buffer<T>> and allocator<A>)
sparrow::buffer< T >::buffer ( const A & a)
inlineexplicitconstexpr

Definition at line 172 of file buffer.hpp.

◆ buffer() [3/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( size_type n,
const A & a )
explicitconstexpr

Definition at line 471 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [4/13]

template<class T>
requires ( std::is_trivially_default_constructible_v<T> && std::is_trivially_destructible_v<T> )
template<allocator A>
requires ( std::is_trivially_default_constructible_v<T> && std::is_trivially_destructible_v<T> )
sparrow::buffer< T >::buffer ( size_type n,
uninitialized_t ,
const A & a )
constexpr

Constructs a buffer whose elements are not initialized.

Precondition
Every element is written before being read.

Definition at line 483 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [5/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( size_type n,
const value_type & v,
const A & a )
constexpr

Definition at line 490 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [6/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( pointer p,
size_type n,
const A & a )
constexpr

Definition at line 498 of file buffer.hpp.

◆ buffer() [7/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( std::initializer_list< value_type > init,
const A & a )
constexpr

Definition at line 505 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [8/13]

template<class T>
template<class It, allocator A>
sparrow::buffer< T >::buffer ( It first,
It last,
const A & a )
constexpr

Definition at line 513 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [9/13]

template<class T>
requires (std::same_as<std::ranges::range_value_t<Range>, T> && !is_buffer_view<Range>)
template<std::ranges::input_range Range, allocator A>
requires (std::same_as<std::ranges::range_value_t<Range>, T> && !is_buffer_view<Range>)
sparrow::buffer< T >::buffer ( const Range & range,
const A & a )
constexpr

Definition at line 522 of file buffer.hpp.

Here is the call graph for this function:

◆ ~buffer()

template<class T>
sparrow::buffer< T >::~buffer ( )

Definition at line 534 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [10/13]

template<class T>
sparrow::buffer< T >::buffer ( const buffer< T > & rhs)
constexpr

Definition at line 540 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [11/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( const buffer< T > & rhs,
const A & a )
constexpr

Definition at line 553 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [12/13]

template<class T>
sparrow::buffer< T >::buffer ( buffer< T > && rhs)
constexprdefaultnoexcept

◆ buffer() [13/13]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( buffer< T > && rhs,
const A & a )
constexpr

Definition at line 566 of file buffer.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ allocate_and_copy()

template<class T>
template<class It>
auto sparrow::buffer< T >::allocate_and_copy ( size_type n,
It first,
It last ) -> pointer
constexpr

Definition at line 1126 of file buffer.hpp.

◆ back() [1/2]

template<class T>
auto sparrow::buffer< T >::back ( )
nodiscardconstexpr

Definition at line 675 of file buffer.hpp.

Here is the call graph for this function:

◆ back() [2/2]

template<class T>
auto sparrow::buffer< T >::back ( ) const
nodiscardconstexpr

Definition at line 682 of file buffer.hpp.

Here is the call graph for this function:

◆ begin() [1/2]

template<class T>
auto sparrow::buffer< T >::begin ( ) const
nodiscardconstexprnoexcept

Definition at line 729 of file buffer.hpp.

Here is the call graph for this function:

◆ begin() [2/2]

template<class T>
auto sparrow::buffer< T >::begin ( )
nodiscardconstexprnoexcept

Definition at line 717 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ capacity()

template<class T>
auto sparrow::buffer< T >::capacity ( ) const
nodiscardconstexprnoexcept

Definition at line 796 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbegin()

template<class T>
auto sparrow::buffer< T >::cbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 741 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cend()

template<class T>
auto sparrow::buffer< T >::cend ( ) const
nodiscardconstexprnoexcept

Definition at line 747 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<class T>
void sparrow::buffer< T >::clear ( )
constexpr

Definition at line 874 of file buffer.hpp.

Here is the caller graph for this function:

◆ copy_initialize()

template<class T>
template<class It>
auto sparrow::buffer< T >::copy_initialize ( It first,
It last,
pointer begin,
allocator_type & a ) -> pointer
constexpr

Definition at line 1184 of file buffer.hpp.

◆ crbegin()

template<class T>
auto sparrow::buffer< T >::crbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 777 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ crend()

template<class T>
auto sparrow::buffer< T >::crend ( ) const
nodiscardconstexprnoexcept

Definition at line 783 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [1/2]

template<class T>
template<class U>
const U * sparrow::buffer< T >::data ( ) const
nodiscardconstexprnoexcept

Definition at line 704 of file buffer.hpp.

◆ data() [2/2]

template<class T>
template<class U>
U * sparrow::buffer< T >::data ( )
nodiscardconstexprnoexcept

Definition at line 690 of file buffer.hpp.

Here is the caller graph for this function:

◆ emplace()

template<class T>
template<class... Args>
buffer< T >::iterator sparrow::buffer< T >::emplace ( const_iterator pos,
Args &&... args )
constexpr

Definition at line 974 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<class T>
bool sparrow::buffer< T >::empty ( ) const
nodiscardconstexprnoexcept

Definition at line 789 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [1/2]

template<class T>
auto sparrow::buffer< T >::end ( ) const
nodiscardconstexprnoexcept

Definition at line 735 of file buffer.hpp.

Here is the call graph for this function:

◆ end() [2/2]

template<class T>
auto sparrow::buffer< T >::end ( )
nodiscardconstexprnoexcept

Definition at line 723 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase() [1/2]

template<class T>
auto sparrow::buffer< T >::erase ( const_iterator first,
const_iterator last )
constexpr

Definition at line 1004 of file buffer.hpp.

Here is the call graph for this function:

◆ erase() [2/2]

template<class T>
auto sparrow::buffer< T >::erase ( const_iterator pos)
constexpr

Definition at line 996 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ front() [1/2]

template<class T>
auto sparrow::buffer< T >::front ( )
nodiscardconstexpr

Definition at line 661 of file buffer.hpp.

Here is the call graph for this function:

◆ front() [2/2]

template<class T>
auto sparrow::buffer< T >::front ( ) const
nodiscardconstexpr

Definition at line 668 of file buffer.hpp.

Here is the call graph for this function:

◆ get_allocator() [1/2]

template<class T>
auto sparrow::buffer_base< T >::get_allocator ( ) const
nodiscardconstexprnoexcept

Definition at line 116 of file buffer.hpp.

Here is the call graph for this function:

◆ get_allocator() [2/2]

template<class T>
auto sparrow::buffer_base< T >::get_allocator ( )
nodiscardconstexprnoexcept

Definition at line 115 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [1/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
const T & value )
constexpr

Definition at line 883 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/8]

template<class T>
template<mpl::iterator_of_type< T > InputIt>
iterator sparrow::buffer< T >::insert ( const_iterator pos,
InputIt first,
InputIt last )
constexpr

◆ insert() [3/8]

template<class T>
template<mpl::iterator_of_type< T > InputIt>
auto sparrow::buffer< T >::insert ( const_iterator pos,
InputIt first,
InputIt last ) -> iterator
constexpr

Definition at line 931 of file buffer.hpp.

◆ insert() [4/8]

template<class T>
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
iterator sparrow::buffer< T >::insert ( const_iterator pos,
R && range )
constexpr

◆ insert() [5/8]

template<class T>
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
R && range ) -> iterator
constexpr

Definition at line 957 of file buffer.hpp.

◆ insert() [6/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
size_type count,
const T & value )
constexpr

Definition at line 899 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [7/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
std::initializer_list< T > ilist )
constexpr

Definition at line 965 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [8/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
T && value )
constexpr

Definition at line 891 of file buffer.hpp.

Here is the call graph for this function:

◆ max_size()

template<class T>
auto sparrow::buffer< T >::max_size ( ) const
nodiscardconstexprnoexcept

Definition at line 818 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( buffer< T > && rhs)
constexpr

Definition at line 609 of file buffer.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( const buffer< T > & rhs)
constexpr

Definition at line 585 of file buffer.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( std::initializer_list< value_type > init)
constexpr

Definition at line 636 of file buffer.hpp.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T>
auto sparrow::buffer< T >::operator[] ( size_type i)
nodiscardconstexpr

Definition at line 647 of file buffer.hpp.

Here is the call graph for this function:

◆ operator[]() [2/2]

template<class T>
auto sparrow::buffer< T >::operator[] ( size_type i) const
nodiscardconstexpr

Definition at line 654 of file buffer.hpp.

Here is the call graph for this function:

◆ pop_back()

template<class T>
void sparrow::buffer< T >::pop_back ( )
constexpr

Definition at line 1029 of file buffer.hpp.

Here is the call graph for this function:

◆ push_back() [1/2]

template<class T>
void sparrow::buffer< T >::push_back ( const T & value)
constexpr

Definition at line 1017 of file buffer.hpp.

Here is the call graph for this function:

◆ push_back() [2/2]

template<class T>
void sparrow::buffer< T >::push_back ( T && value)
constexpr

Definition at line 1023 of file buffer.hpp.

Here is the call graph for this function:

◆ rbegin() [1/2]

template<class T>
auto sparrow::buffer< T >::rbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 765 of file buffer.hpp.

Here is the call graph for this function:

◆ rbegin() [2/2]

template<class T>
auto sparrow::buffer< T >::rbegin ( )
nodiscardconstexprnoexcept

Definition at line 753 of file buffer.hpp.

Here is the call graph for this function:

◆ rend() [1/2]

template<class T>
auto sparrow::buffer< T >::rend ( ) const
nodiscardconstexprnoexcept

Definition at line 771 of file buffer.hpp.

Here is the call graph for this function:

◆ rend() [2/2]

template<class T>
auto sparrow::buffer< T >::rend ( )
nodiscardconstexprnoexcept

Definition at line 759 of file buffer.hpp.

Here is the call graph for this function:

◆ reserve()

template<class T>
void sparrow::buffer< T >::reserve ( size_type new_cap)
constexpr

Definition at line 824 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize() [1/2]

template<class T>
void sparrow::buffer< T >::resize ( size_type new_size)
constexpr

Definition at line 1037 of file buffer.hpp.

Here is the call graph for this function:

◆ resize() [2/2]

template<class T>
void sparrow::buffer< T >::resize ( size_type new_size,
const value_type & value )
constexpr

Definition at line 1049 of file buffer.hpp.

Here is the call graph for this function:

◆ shrink_to_fit()

template<class T>
void sparrow::buffer< T >::shrink_to_fit ( )
constexpr

Definition at line 865 of file buffer.hpp.

Here is the call graph for this function:

◆ size()

template<class T>
auto sparrow::buffer< T >::size ( ) const
nodiscardconstexprnoexcept

Definition at line 807 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

template<class T>
void sparrow::buffer< T >::swap ( buffer< T > & rhs)
constexprnoexcept

Definition at line 1061 of file buffer.hpp.

Here is the call graph for this function:

The documentation for this class was generated from the following file: