 |
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
6 #ifndef swcdb_core_VectorsVector_h
7 #define swcdb_core_VectorsVector_h
12 namespace SWC {
namespace Core {
16 template<
typename VectorsT,
typename VectorT,
17 typename VectorT::size_type SIZE,
18 typename VectorT::size_type GROW = SIZE/4,
19 typename VectorT::size_type SPLIT = SIZE/2>
36 : VectorsT(std::move(other)) {
43 VectorsT::operator=(other);
49 VectorsT::operator=(std::move(other));
60 return !(*
this == other);
66 if(GROW > 1 && vec.capacity() == vec.size() && vec.capacity() >= GROW) {
67 size_t sz = vec.size() + GROW;
68 if((sz > SIZE ? (sz = SIZE) : sz) > vec.capacity())
308 typename VectorT::const_iterator
_item;
315 ?
typename VectorT::const_iterator() :
_vector->cbegin()) {
322 if(!offset || offset < _vector->
size()) {
347 if(!offset || offset < _vector->
size()) {
357 operator bool() const noexcept {
377 return _vector == other._vector &&
_item == other._item;
398 ?
typename VectorT::iterator() :
_vector->begin()) {
402 explicit Iterator(VectorsT& a_vectors,
size_t offset) noexcept
405 if(!offset || offset < _vector->
size()) {
430 if(!offset || offset < _vector->
size()) {
440 operator bool() const noexcept {
460 return _vector == other._vector &&
_item == other._item;
483 auto it_b =
_vector->cbegin() + SPLIT;
485 n_vector->reserve(SPLIT + 1);
487 n_vector->assign(it_b,
_vector->cend());
559 T get(
size_t offset) noexcept {
560 return T(*
this, offset);
565 T get(
size_t offset)
const noexcept {
566 return T(*
this, offset);
572 return get<Iterator>();
577 return get<Iterator>(offset);
582 return get<ConstIterator>();
587 return get<ConstIterator>(offset);
593 size_t sz = VectorsT::capacity() *
sizeof(VectorT);
594 for(
auto& vec : *
this)
602 for(
auto& vec : *
this)
610 return VectorsT::front().front();
615 return VectorsT::back().back();
620 return VectorsT::front().front();
625 return VectorsT::back().back();
630 auto it = get<Iterator>(pos);
631 return it ? &it.item() :
nullptr;
637 if(VectorsT::empty() || VectorsT::back().
size() >= SIZE) {
638 VectorsT::emplace_back();
640 VectorsT::back().reserve(sz);
648 VectorsT::back().push_back(value);
654 VectorsT::back().push_back(std::move(value));
661 for(
auto it = other.begin(); it != other.cend(); ++it)
662 VectorsT::emplace_back(std::move(*it));
664 other.shrink_to_fit();
670 to.reserve(to.size() + split_at);
671 for(
auto it = VectorsT::begin() + split_at; it != VectorsT::cend(); ++it)
672 to.emplace_back(std::move(*it));
673 VectorsT::erase(VectorsT::cbegin() + split_at, VectorsT::cend());
676 void print(std::ostream& out)
const {
677 out <<
"VectorsVector(" <<
VectorsT::size() <<
'/' << VectorsT::capacity()
679 for(
auto& vec : *
this)
680 out << vec.size() <<
'/' << vec.capacity() <<
',';
692 #endif // swcdb_core_VectorsVector_h
SWC_CAN_INLINE void ensure()
constexpr static SWC_CAN_INLINE size_t need_reserve(VectorT &vec)
constexpr SWC_CAN_INLINE value_type & front() noexcept
typename VectorT::value_type value_type
constexpr SWC_CAN_INLINE Iterator GetIterator() noexcept
constexpr SWC_CAN_INLINE size_t count() const noexcept
constexpr SWC_CAN_INLINE ConstIterator & at(size_t offset) noexcept
constexpr SWC_CAN_INLINE const value_type & front() const noexcept
constexpr SWC_CAN_INLINE bool operator!=(const VectorsVector &other) const noexcept
constexpr SWC_CAN_INLINE T get(size_t offset) noexcept
constexpr SWC_CAN_INLINE value_type * operator[](size_t pos) noexcept
constexpr SWC_CAN_INLINE T get(size_t offset) const noexcept
constexpr SWC_CAN_INLINE VectorsVector() noexcept
constexpr SWC_CAN_INLINE Iterator(VectorsT &a_vectors, size_t offset) noexcept
SWC_CAN_INLINE void ensure()
SWC_CAN_INLINE void split(size_t split_at, VectorsVector &to)
constexpr SWC_CAN_INLINE ConstIterator(const VectorsT &a_vectors) noexcept
constexpr SWC_CAN_INLINE Iterator & at(size_t offset) noexcept
SWC_CAN_INLINE void remove(size_t number) noexcept
SWC_CAN_INLINE void remove() noexcept
SWC_CAN_INLINE void push_back(value_type &&value)
constexpr SWC_CAN_INLINE Iterator GetIterator(size_t offset) noexcept
constexpr SWC_CAN_INLINE bool next() noexcept
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator() const noexcept
SWC_CAN_INLINE void add(VectorsVector &&other)
constexpr SWC_CAN_INLINE size_t size_of_internal() const noexcept
constexpr SWC_CAN_INLINE value_type & back() noexcept
The SWC-DB C++ namespace 'SWC'.
VectorsT::const_iterator _vector
constexpr SWC_CAN_INLINE bool operator==(const ConstIterator &other) const noexcept
bool SWC_PURE_FUNC operator==(ItemPtr l, ItemPtr r)
constexpr SWC_CAN_INLINE bool operator==(const Iterator &other) const noexcept
SWC_CAN_INLINE void insert(const value_type &value)
constexpr SWC_CAN_INLINE const value_type & back() const noexcept
SWC_CAN_INLINE VectorsVector(const VectorsVector &other)
SWC_CAN_INLINE void push_back(const value_type &value)
constexpr SWC_CAN_INLINE value_type & item() noexcept
constexpr SWC_CAN_INLINE Iterator & operator=(const Iterator &other) noexcept
constexpr SWC_CAN_INLINE Iterator & operator++() noexcept
constexpr SWC_CAN_INLINE ConstIterator & operator++() noexcept
void print(std::ostream &out) const
constexpr SWC_CAN_INLINE Iterator(VectorsT &a_vectors) noexcept
constexpr SWC_CAN_INLINE const value_type & item() const noexcept
VectorT::const_iterator _item
SWC_CAN_INLINE VectorsVector & operator=(const VectorsVector &other)
VectorsT::iterator _vector
constexpr SWC_CAN_INLINE T get() const noexcept
constexpr SWC_CAN_INLINE ConstIterator & operator=(const ConstIterator &other) noexcept
constexpr SWC_CAN_INLINE T get() noexcept
SWC_CAN_INLINE VectorsVector & operator=(VectorsVector &&other) noexcept
SWC_CAN_INLINE void insert(value_type &&value)
constexpr SWC_CAN_INLINE bool operator==(const VectorsVector &other) const noexcept
constexpr SWC_CAN_INLINE VectorsVector(VectorsVector &&other) noexcept
constexpr SWC_CAN_INLINE ConstIterator(const VectorsT &a_vectors, size_t offset) noexcept
~VectorsVector() noexcept
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator(size_t offset) const noexcept
const VectorsT & _vectors
constexpr SWC_CAN_INLINE ConstIterator(const ConstIterator &other) noexcept
constexpr SWC_CAN_INLINE bool next() noexcept
constexpr SWC_CAN_INLINE Iterator(const Iterator &other) noexcept