libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal::VectorViewBase< CRTP, T > Class Template Reference
Inheritance diagram for gimbal::VectorViewBase< CRTP, T >:
gimbal::tags::VectorBase gimbal::ReadWriteContiguousIndexable< CRTP, Size, T > gimbal::RandomAccessIterable< CRTP, Size, T > gimbal::ReadWriteIndexable< CRTP, Key, Value, Writable > gimbal::Vector< void * >

Public Types

using VectorViewBaseType = VectorViewBase< CRTP, T >
 
using DerivedType = CRTP
 
using IterableType = RandomAccessIterable< CRTP, Size, T >
 
using IndexableType = ReadWriteContiguousIndexable< CRTP, Size, T >
 
using value_type = T
 
using allocator_type = Context *
 
using size_type = Size
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = T *
 
using const_pointer = const T *
 
using iterator = typename IterableType::iterator
 
using const_iterator = typename IterableType::const_iterator
 
using reverse_iterator = typename IterableType::reverse_iterator
 
using reverse_const_iterator = typename IterableType::reverse_const_iterator
 
- Public Types inherited from gimbal::RandomAccessIterable< CRTP, Size, T >
using iterator = RandomAccessIterator< CRTP, Size, T, false >
 
using reverse_iterator = RandomAccessIterator< CRTP, Size, T, true >
 
using const_iterator = RandomAccessIterator< std::add_const_t< CRTP >, Size, T, false >
 
using reverse_const_iterator = RandomAccessIterator< std::add_const_t< CRTP >, Size, T, true >
 

Public Member Functions

 operator const GblArrayList * () const
 
const_reference getElement_ (size_type index) const
 
reference getElement_ (size_type index)
 
void setElement_ (size_type index, value_type value)
 
size_t getElementCount_ (void) const
 
bool isEmpty (void) const
 
bool isStack (void) const
 
bool isHeap (void) const
 
std::vector< value_type > toStdVector (void) const
 
Size getStackBytes (void) const
 
Context * getContext (void) const
 
allocator_type get_allocator (void) const
 
Size getSize (void) const
 
Size getSizeBytes (void) const
 
Size size_bytes (void) const
 
Size getCapacity (void) const
 
Size capacity (void) const
 
Size getElementSize (void) const
 
size_type element_size (void) const
 
size_type max_size (void) const
 
const void * getData (void) const
 
constexpr pointer data (void)
 
constexpr const_pointer data (void) const
 
T & front (void) const
 
T & back (void) const
 
- Public Member Functions inherited from gimbal::ReadWriteContiguousIndexable< CRTP, Size, T >
void checkBounds (Size index) const
 
Size size (void) const
 
Size length (void) const
 
Size empty (void) const
 
T at (Size index) const
 
IndexableProxy at (Size index)
 
T front (Size index) const
 
IndexableProxy front (void)
 
T back (void) const
 
IndexableProxy back (void)
 
- Public Member Functions inherited from gimbal::ReadWriteIndexable< CRTP, Key, Value, Writable >
Value operator[] (Key key) const
 
- Public Member Functions inherited from gimbal::RandomAccessIterable< CRTP, Size, T >
iterator begin (void)
 
auto begin (void) const
 
auto rbegin (void)
 
auto rbegin (void) const
 
iterator end (void)
 
auto end (void) const
 
auto rend (void)
 
auto rend (void) const
 
const_iterator cbegin (void) const
 
auto crbegin (void) const
 
const_iterator cend (void) const
 
auto crend (void) const
 

Protected Member Functions

decltype(auto) vec_ (void) const
 
decltype(auto) vec_ (void)
 
void * at_ (Size index) const
 

Friends

bool operator== (const CRTP &vec, const type_compatible_container_readable< T > auto &con)
 
constexpr auto operator<=> (const CRTP &vec, const type_compatible_container_readable< T > auto &con) noexcept
 
bool operator== (const CRTP &vec, const VectorView< T > &rhs)
 
constexpr auto operator<=> (const CRTP &vec, const VectorView< T > &rhs) noexcept
 

Detailed Description

template<typename CRTP, typename T>
class gimbal::VectorViewBase< CRTP, T >

Definition at line 46 of file gimbal_vector.hpp.

Member Typedef Documentation

◆ VectorViewBaseType

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::VectorViewBaseType = VectorViewBase<CRTP, T>

Definition at line 52 of file gimbal_vector.hpp.

◆ DerivedType

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::DerivedType = CRTP

Definition at line 53 of file gimbal_vector.hpp.

◆ IterableType

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::IterableType = RandomAccessIterable<CRTP, Size, T>

Definition at line 54 of file gimbal_vector.hpp.

◆ IndexableType

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::IndexableType = ReadWriteContiguousIndexable<CRTP, Size, T>

Definition at line 55 of file gimbal_vector.hpp.

◆ value_type

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::value_type = T

Definition at line 58 of file gimbal_vector.hpp.

◆ allocator_type

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::allocator_type = Context*

Definition at line 59 of file gimbal_vector.hpp.

◆ size_type

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::size_type = Size

Definition at line 60 of file gimbal_vector.hpp.

◆ difference_type

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::difference_type = std::ptrdiff_t

Definition at line 61 of file gimbal_vector.hpp.

◆ reference

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::reference = value_type&

Definition at line 62 of file gimbal_vector.hpp.

◆ const_reference

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::const_reference = const value_type&

Definition at line 63 of file gimbal_vector.hpp.

◆ pointer

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::pointer = T*

Definition at line 64 of file gimbal_vector.hpp.

◆ const_pointer

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::const_pointer = const T*

Definition at line 65 of file gimbal_vector.hpp.

◆ iterator

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::iterator = typename IterableType::iterator

Definition at line 67 of file gimbal_vector.hpp.

◆ const_iterator

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::const_iterator = typename IterableType::const_iterator

Definition at line 68 of file gimbal_vector.hpp.

◆ reverse_iterator

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::reverse_iterator = typename IterableType::reverse_iterator

Definition at line 69 of file gimbal_vector.hpp.

◆ reverse_const_iterator

template<typename CRTP , typename T >
using gimbal::VectorViewBase< CRTP, T >::reverse_const_iterator = typename IterableType::reverse_const_iterator

Definition at line 70 of file gimbal_vector.hpp.

Member Function Documentation

◆ vec_() [1/2]

template<typename CRTP , typename T >
decltype(auto) gimbal::VectorViewBase< CRTP, T >::vec_ ( void  ) const
inlineprotected

Definition at line 73 of file gimbal_vector.hpp.

73 {
74 return static_cast<const CRTP*>(this)->getVector_();
75 }

◆ vec_() [2/2]

template<typename CRTP , typename T >
decltype(auto) gimbal::VectorViewBase< CRTP, T >::vec_ ( void  )
inlineprotected

Definition at line 77 of file gimbal_vector.hpp.

77 {
78 return static_cast<CRTP*>(this)->getVector_();
79 }

◆ at_()

template<typename CRTP , typename T >
void * gimbal::VectorViewBase< CRTP, T >::at_ ( Size  index) const
inlineprotected

Definition at line 81 of file gimbal_vector.hpp.

81 {
82 void* pData = nullptr;
83 Exception::checkThrow([&]() {
84 pData = GblArrayList_at(vec_(), index);
85 });
86 return pData;
87 }

◆ operator const GblArrayList *()

template<typename CRTP , typename T >
gimbal::VectorViewBase< CRTP, T >::operator const GblArrayList * ( ) const
inline

Definition at line 90 of file gimbal_vector.hpp.

90{ return vec_(); }

◆ getElement_() [1/2]

template<typename CRTP , typename T >
const_reference gimbal::VectorViewBase< CRTP, T >::getElement_ ( size_type  index) const
inline

Definition at line 93 of file gimbal_vector.hpp.

93 {
94 return *static_cast<const T*>(at_(index));
95 }

◆ getElement_() [2/2]

template<typename CRTP , typename T >
reference gimbal::VectorViewBase< CRTP, T >::getElement_ ( size_type  index)
inline

Definition at line 97 of file gimbal_vector.hpp.

97 {
98 return *static_cast<T*>(at_(index));
99 }

◆ setElement_()

template<typename CRTP , typename T >
void gimbal::VectorViewBase< CRTP, T >::setElement_ ( size_type  index,
value_type  value 
)
inline

Definition at line 101 of file gimbal_vector.hpp.

101 {
102 *static_cast<pointer>(at_(index)) = value;
103 }

◆ getElementCount_()

template<typename CRTP , typename T >
size_t gimbal::VectorViewBase< CRTP, T >::getElementCount_ ( void  ) const
inline

Definition at line 105 of file gimbal_vector.hpp.

105 {
106 return getSize();
107 }

◆ isEmpty()

template<typename CRTP , typename T >
bool gimbal::VectorViewBase< CRTP, T >::isEmpty ( void  ) const
inline

Definition at line 112 of file gimbal_vector.hpp.

112 {
113 return GblArrayList_empty(vec_());
114 }

◆ isStack()

template<typename CRTP , typename T >
bool gimbal::VectorViewBase< CRTP, T >::isStack ( void  ) const
inline

Definition at line 116 of file gimbal_vector.hpp.

116 {
117 return GblArrayList_stack(vec_());
118 }

◆ isHeap()

template<typename CRTP , typename T >
bool gimbal::VectorViewBase< CRTP, T >::isHeap ( void  ) const
inline

Definition at line 120 of file gimbal_vector.hpp.

120{ return !isStack(); }

◆ toStdVector()

template<typename CRTP , typename T >
std::vector< value_type > gimbal::VectorViewBase< CRTP, T >::toStdVector ( void  ) const
inline

Definition at line 127 of file gimbal_vector.hpp.

127 {
128 std::vector<value_type> stdVec(&front(), &back());
129 }

◆ getStackBytes()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::getStackBytes ( void  ) const
inline

Definition at line 131 of file gimbal_vector.hpp.

131 {
132 return GblArrayList_stackBytes(vec_());
133 }

◆ getContext()

template<typename CRTP , typename T >
Context * gimbal::VectorViewBase< CRTP, T >::getContext ( void  ) const
inline

Definition at line 135 of file gimbal_vector.hpp.

135 {
136 return Context::fromGblObj(GblArrayList_context(vec_()));
137 }

◆ get_allocator()

template<typename CRTP , typename T >
allocator_type gimbal::VectorViewBase< CRTP, T >::get_allocator ( void  ) const
inline

Definition at line 139 of file gimbal_vector.hpp.

139 {
140 return getContext();
141 }

◆ getSize()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::getSize ( void  ) const
inline

Definition at line 143 of file gimbal_vector.hpp.

143 {
144 return GblArrayList_size(vec_());
145 }

◆ getSizeBytes()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::getSizeBytes ( void  ) const
inline

Definition at line 147 of file gimbal_vector.hpp.

147 {
148 return getSize() * getElementSize();
149 }

◆ size_bytes()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::size_bytes ( void  ) const
inline

Definition at line 151 of file gimbal_vector.hpp.

151 {
152 return getSizeBytes();
153 }

◆ getCapacity()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::getCapacity ( void  ) const
inline

Definition at line 155 of file gimbal_vector.hpp.

155 {
156 return GblArrayList_capacity(vec_());
157 }

◆ capacity()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::capacity ( void  ) const
inline

Definition at line 159 of file gimbal_vector.hpp.

159 {
160 return getCapacity();
161 }

◆ getElementSize()

template<typename CRTP , typename T >
Size gimbal::VectorViewBase< CRTP, T >::getElementSize ( void  ) const
inline

Definition at line 163 of file gimbal_vector.hpp.

163 {
164 return GblArrayList_elementSize(vec_());
165 }

◆ element_size()

template<typename CRTP , typename T >
size_type gimbal::VectorViewBase< CRTP, T >::element_size ( void  ) const
inline

Definition at line 167 of file gimbal_vector.hpp.

167{ return getElementSize(); }

◆ max_size()

template<typename CRTP , typename T >
size_type gimbal::VectorViewBase< CRTP, T >::max_size ( void  ) const
inline

Definition at line 169 of file gimbal_vector.hpp.

169 { //kinda bullshit, no idea if you can allocate that much
170 return std::numeric_limits<size_type>::max();
171 }

◆ getData()

template<typename CRTP , typename T >
const void * gimbal::VectorViewBase< CRTP, T >::getData ( void  ) const
inline

Definition at line 173 of file gimbal_vector.hpp.

173 {
174 return GblArrayList_data(vec_());
175 }

◆ data() [1/2]

template<typename CRTP , typename T >
constexpr pointer gimbal::VectorViewBase< CRTP, T >::data ( void  )
inlineconstexpr

Definition at line 177 of file gimbal_vector.hpp.

177 {
178 return static_cast<pointer>(const_cast<void*>(getData()));
179 }

◆ data() [2/2]

template<typename CRTP , typename T >
constexpr const_pointer gimbal::VectorViewBase< CRTP, T >::data ( void  ) const
inlineconstexpr

Definition at line 181 of file gimbal_vector.hpp.

181 {
182 return static_cast<const_pointer>(const_cast<VectorViewBaseType*>(this)->data());
183 }

◆ front()

template<typename CRTP , typename T >
T & gimbal::VectorViewBase< CRTP, T >::front ( void  ) const
inline

Definition at line 185 of file gimbal_vector.hpp.

185 {
186 T* pValue = nullptr;
187 Exception::checkThrow([&]() {
188 pValue = reinterpret_cast<T*>(GblArrayList_front(vec_()));
189 });
190 return *pValue;
191 }

◆ back()

template<typename CRTP , typename T >
T & gimbal::VectorViewBase< CRTP, T >::back ( void  ) const
inline

Definition at line 193 of file gimbal_vector.hpp.

193 {
194 T* pValue = nullptr;
195 Exception::checkThrow([&]() {
196 pValue = reinterpret_cast<T*>(GblArrayList_back(vec_()));
197 });
198 return *pValue;
199 }

Friends And Related Symbol Documentation

◆ operator== [1/2]

template<typename CRTP , typename T >
bool operator== ( const CRTP &  vec,
const type_compatible_container_readable< T > auto &  con 
)
friend

Definition at line 201 of file gimbal_vector.hpp.

201 {
202 if(std::size(vec) != std::size(con)) return false;
203 return std::equal(vec.cbegin(), vec.cend(), std::cbegin(con));
204 }

◆ operator<=> [1/2]

template<typename CRTP , typename T >
constexpr auto operator<=> ( const CRTP &  vec,
const type_compatible_container_readable< T > auto &  con 
)
friend

Definition at line 206 of file gimbal_vector.hpp.

206 {
207#ifdef GBL_LEX_CMP_3WAY
208 return std::lexicographical_compare_three_way(std::cbegin(vec), std::cend(vec), std::cbegin(con), std::cend(con));
209#else
210 return std::lexicographical_compare(std::cbegin(vec), std::cend(vec), std::cbegin(con), std::cend(con));
211#endif
212 }

◆ operator== [2/2]

template<typename CRTP , typename T >
bool operator== ( const CRTP &  vec,
const VectorView< T > &  rhs 
)
friend

Definition at line 214 of file gimbal_vector.hpp.

214 {
215 if(std::size(vec) != std::size(rhs)) return false;
216 return std::equal(vec.cbegin(), vec.cend(), rhs.cbegin());
217 }

◆ operator<=> [2/2]

template<typename CRTP , typename T >
constexpr auto operator<=> ( const CRTP &  vec,
const VectorView< T > &  rhs 
)
friend

Definition at line 219 of file gimbal_vector.hpp.

219 {
220#ifdef GBL_LEX_CMP_3WAY
221 return std::lexicographical_compare_three_way(std::cbegin(vec), std::cend(vec), std::cbegin(rhs), std::cend(rhs));
222#else
223 return std::lexicographical_compare(std::cbegin(vec), std::cend(vec), std::cbegin(rhs), std::cend(rhs));
224#endif
225 }

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