Go to the documentation of this file.
14 #ifndef LLVM_VECSMALL_ADT_SMALLVECTOR_H
15 #define LLVM_VECSMALL_ADT_SMALLVECTOR_H
22 #include <initializer_list>
27 #define LLVM_VECSMALL_NODISCARD
28 #define LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE inline
29 #define LLVM_VECSMALL_UNLIKELY(x) (x)
56 struct IsPod : std::integral_constant<bool, std::is_standard_layout<T>::value &&
57 std::is_trivial<T>::value>
75 void grow_pod(
void* FirstEl,
size_t MinSizeInBytes,
size_t TSize);
96 template <
typename T,
unsigned N>
102 template <
typename T,
typename =
void>
106 template <
typename,
unsigned>
177 const_iterator
end()
const
276 template <
typename T,
bool isPodLike>
295 template <
typename It1,
typename It2>
298 std::uninitialized_copy(std::make_move_iterator(I), std::make_move_iterator(E), Dest);
303 template <
typename It1,
typename It2>
306 std::uninitialized_copy(I, E, Dest);
312 void grow(
size_t MinSize = 0);
319 ::new ((
void*)this->
end()) T(Elt);
339 template <
typename T,
bool isPodLike>
342 size_t CurCapacity = this->capacity();
343 size_t CurSize = this->
size();
346 if (NewCapacity < MinSize)
347 NewCapacity = MinSize;
348 T* NewElts =
static_cast<T*
>(malloc(NewCapacity *
sizeof(T)));
351 this->uninitialized_move(this->begin(), this->end(), NewElts);
354 destroy_range(this->begin(), this->end());
357 if (!this->isSmall())
360 this->setEnd(NewElts + CurSize);
361 this->BeginX = NewElts;
362 this->CapacityX = this->begin() + NewCapacity;
367 template <
typename T>
382 template <
typename It1,
typename It2>
391 template <
typename It1,
typename It2>
395 std::uninitialized_copy(I, E, Dest);
400 template <
typename T1,
typename T2>
402 T1* I, T1* E, T2* Dest,
403 typename std::enable_if<
411 memcpy(Dest, I, (E - I) *
sizeof(T));
418 this->
grow_pod(MinSize *
sizeof(T),
sizeof(T));
426 memcpy(this->
end(), &Elt,
sizeof(T));
438 template <
typename T>
476 if (N < this->
size())
481 else if (N > this->
size())
485 for (
auto I = this->
end(), E = this->
begin() + N; I != E; ++I)
493 if (N < this->
size())
498 else if (N > this->
size())
502 std::uninitialized_fill(this->
end(), this->
begin() + N, NV);
523 template <
typename in_iter>
524 void append(in_iter in_start, in_iter in_end)
526 size_type NumInputs = std::distance(in_start, in_end);
529 this->
grow(this->
size() + NumInputs);
541 this->
grow(this->
size() + NumInputs);
544 std::uninitialized_fill_n(this->
end(), NumInputs, Elt);
550 append(IL.begin(), IL.end());
559 std::uninitialized_fill(this->
begin(), this->
end(), Elt);
573 assert(I >= this->
begin() &&
"Iterator to erase is out of bounds.");
574 assert(I < this->
end() &&
"Erasing at past-the-end iterator.");
590 assert(
S >= this->
begin() &&
"Range to erase is out of bounds.");
591 assert(S <= E &&
"Trying to erase invalid range.");
592 assert(E <= this->
end() &&
"Trying to erase past the end.");
605 if (I == this->
end())
608 return this->
end() - 1;
611 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
612 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
616 size_t EltNo = I - this->
begin();
618 I = this->
begin() + EltNo;
623 std::move_backward(I, this->
end() - 1, this->
end());
629 if (I <= EltPtr && EltPtr < this->
EndX)
638 if (I == this->
end())
641 return this->
end() - 1;
644 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
645 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
649 size_t EltNo = I - this->
begin();
651 I = this->
begin() + EltNo;
655 std::move_backward(I, this->
end() - 1, this->
end());
660 const T* EltPtr = &Elt;
661 if (I <= EltPtr && EltPtr < this->
EndX)
671 size_t InsertElt = I - this->
begin();
673 if (I == this->
end())
676 return this->
begin() + InsertElt;
679 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
680 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
686 I = this->
begin() + InsertElt;
692 if (
size_t(this->
end() - I) >= NumToInsert)
694 T* OldEnd = this->
end();
695 append(std::move_iterator<iterator>(this->
end() - NumToInsert),
696 std::move_iterator<iterator>(this->
end()));
699 std::move_backward(I, OldEnd - NumToInsert, OldEnd);
709 T* OldEnd = this->
end();
711 size_t NumOverwritten = OldEnd - I;
718 std::uninitialized_fill_n(OldEnd, NumToInsert - NumOverwritten, Elt);
722 template <
typename ItTy>
726 size_t InsertElt = I - this->
begin();
728 if (I == this->
end())
731 return this->
begin() + InsertElt;
734 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
735 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
737 size_t NumToInsert = std::distance(From, To);
743 I = this->
begin() + InsertElt;
749 if (
size_t(this->
end() - I) >= NumToInsert)
751 T* OldEnd = this->
end();
752 append(std::move_iterator<iterator>(this->
end() - NumToInsert),
753 std::move_iterator<iterator>(this->
end()));
756 std::move_backward(I, OldEnd - NumToInsert, OldEnd);
766 T* OldEnd = this->
end();
768 size_t NumOverwritten = OldEnd - I;
772 for (T* J = I; NumOverwritten > 0; --NumOverwritten)
786 insert(I, IL.begin(), IL.end());
789 template <
typename... ArgTypes>
794 ::new ((
void*)this->
end()) T(std::forward<ArgTypes>(Args)...);
810 return !(*
this == RHS);
815 return std::lexicographical_compare(this->
begin(), this->
end(), RHS.
begin(),
835 template <
typename T>
842 if (!this->isSmall() && !RHS.
isSmall())
849 if (RHS.
size() > this->capacity())
850 this->grow(RHS.
size());
855 size_t NumShared = this->
size();
856 if (NumShared > RHS.
size())
857 NumShared = RHS.
size();
858 for (
size_type i = 0; i != NumShared; ++i)
864 size_t EltDiff = this->
size() - RHS.
size();
865 this->uninitialized_copy(this->begin() + NumShared, this->end(), RHS.
end());
867 this->destroy_range(this->begin() + NumShared, this->end());
868 this->setEnd(this->begin() + NumShared);
870 else if (RHS.
size() > this->size())
872 size_t EltDiff = RHS.
size() - this->
size();
873 this->uninitialized_copy(RHS.
begin() + NumShared, RHS.
end(), this->end());
874 this->setEnd(this->end() + EltDiff);
875 this->destroy_range(RHS.
begin() + NumShared, RHS.
end());
880 template <
typename T>
889 size_t RHSSize = RHS.
size();
890 size_t CurSize = this->
size();
891 if (CurSize >= RHSSize)
898 NewEnd = this->begin();
901 this->destroy_range(NewEnd, this->end());
904 this->setEnd(NewEnd);
911 if (this->capacity() < RHSSize)
914 this->destroy_range(this->begin(), this->end());
915 this->setEnd(this->begin());
926 this->uninitialized_copy(RHS.
begin() + CurSize, RHS.
end(), this->begin() + CurSize);
929 this->setEnd(this->begin() + RHSSize);
933 template <
typename T>
943 this->destroy_range(this->begin(), this->end());
944 if (!this->isSmall())
946 this->BeginX = RHS.BeginX;
947 this->EndX = RHS.EndX;
948 this->CapacityX = RHS.CapacityX;
955 size_t RHSSize = RHS.size();
956 size_t CurSize = this->
size();
957 if (CurSize >= RHSSize)
962 NewEnd =
std::move(RHS.begin(), RHS.end(), NewEnd);
965 this->destroy_range(NewEnd, this->end());
966 this->setEnd(NewEnd);
978 if (this->capacity() < RHSSize)
981 this->destroy_range(this->begin(), this->end());
982 this->setEnd(this->begin());
989 std::move(RHS.begin(), RHS.begin() + CurSize, this->begin());
993 this->uninitialized_move(RHS.begin() + CurSize, RHS.end(), this->begin() + CurSize);
996 this->setEnd(this->begin() + RHSSize);
1006 template <
typename T,
unsigned N>
1011 template <
typename T>
1015 template <
typename T>
1028 template <
typename T,
unsigned N>
1044 template <
typename ItTy>
1106 template <
typename T,
unsigned N>
1109 return X.capacity_in_bytes();
1117 template <
typename T>
1125 template <
typename T,
unsigned N>
1141 if (NewCapacityInBytes < MinSizeInBytes)
1142 NewCapacityInBytes = MinSizeInBytes;
1147 NewElts = malloc(NewCapacityInBytes);
1150 memcpy(NewElts, this->
BeginX, CurSizeBytes);
1155 NewElts = realloc(this->
BeginX, NewCapacityInBytes);
1157 assert(NewElts &&
"Out of memory");
1159 this->
EndX = (
char*)NewElts + CurSizeBytes;
const_reference back() const
std::aligned_union< 1, T >::type U
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
void push_back(const T &Elt)
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE iterator begin()
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool operator<(const SmallVectorImpl &RHS) const
auto copy(const Range &range, OutputIt out) -> OutputIt
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE reference operator[](size_type idx)
size_type max_size() const
#define LLVM_VECSMALL_UNLIKELY(x)
span_CONFIG_SIZE_TYPE size_t
#define LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE
const SmallVector & operator=(std::initializer_list< T > IL)
reverse_iterator rbegin()
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE const_iterator begin() const
SmallVector(SmallVectorImpl< T > &&RHS)
void push_back(const T &Elt)
size_t capacity_in_bytes() const
capacity_in_bytes - This returns capacity()*sizeof(T).
SmallVectorTemplateCommon< T >::U InlineElts[N - 1]
SmallVector(size_t Size, const T &Value=T())
SmallVector(SmallVector &&RHS)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void append(std::initializer_list< T > IL)
#define LLVM_VECSMALL_NODISCARD
iterator insert(iterator I, size_type NumToInsert, const T &Elt)
const typedef T & const_reference
void grow_pod(size_t MinSizeInBytes, size_t TSize)
const_reverse_iterator rend() const
void grow(size_t MinSize=0)
std::reverse_iterator< iterator > reverse_iterator
void emplace_back(ArgTypes &&... Args)
const SmallVector & operator=(SmallVectorImpl< T > &&RHS)
ptrdiff_t difference_type
pointer data()
Return a pointer to the vector's buffer, even if empty().
size_t capacity() const
Return the total number of elements in the currently allocated buffer.
void swap(SmallVectorImpl &RHS)
size_t size_in_bytes() const
This returns size()*sizeof(T).
span_constexpr std::size_t size(span< T, Extent > const &spn)
SuperClass::const_iterator const_iterator
LLVM_VECSMALL_NODISCARD bool empty() const
const_pointer data() const
Return a pointer to the vector's buffer, even if empty().
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE const_iterator end() const
static void uninitialized_move(It1 I, It1 E, It2 Dest)
void append(size_type NumInputs, const T &Elt)
Add the specified range to the end of the SmallVector.
void insert(iterator I, std::initializer_list< T > IL)
void reserve(size_type N)
iterator erase(const_iterator CI)
SmallVector(std::initializer_list< T > IL)
void grow(size_t MinSize=0)
iterator insert(iterator I, T &&Elt)
This is all the non-templated stuff common to all SmallVectors.
SmallVector(ItTy S, ItTy E)
const T & move(const T &v)
void assign(size_type NumElts, const T &Elt)
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
void resize(size_type N, const T &NV)
bool operator==(const SmallVectorImpl &RHS) const
SmallVectorStorage< T, N > Storage
Inline space for elements which aren't stored in the base class.
bool operator!=(const SmallVectorImpl &RHS) const
SmallVectorTemplateBase< T, IsPod< T >::value > SuperClass
iterator insert(iterator I, ItTy From, ItTy To)
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE iterator end()
std::reverse_iterator< const_iterator > const_reverse_iterator
const SmallVector & operator=(SmallVector &&RHS)
const_reverse_iterator rbegin() const
const SmallVector & operator=(const SmallVector &RHS)
const_reference front() const
SmallVectorBase(void *FirstEl, size_t Size)
const typedef T * const_pointer
SuperClass::iterator iterator
LLVM_VECSMALL_ATTRIBUTE_ALWAYS_INLINE const_reference operator[](size_type idx) const
#define assert(condition)
static void destroy_range(T *S, T *E)
SmallVectorTemplateBase(size_t Size)
const typedef T * const_iterator
iterator insert(iterator I, const T &Elt)
void assign(std::initializer_list< T > IL)
static void uninitialized_copy(T1 *I, T1 *E, T2 *Dest, typename std::enable_if< std::is_same< typename std::remove_const< T1 >::type, T2 >::value >::type *=nullptr)
void grow_pod(void *FirstEl, size_t MinSizeInBytes, size_t TSize)
iterator erase(const_iterator CS, const_iterator CE)
SmallVectorImpl(const SmallVectorImpl &)=delete
LLVM_VECSMALL_NODISCARD T pop_back_val()
SmallVectorImpl & operator=(const SmallVectorImpl &RHS)
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
SuperClass::size_type size_type
void resetToSmall()
Put this vector in a state of being small.
SmallVectorTemplateCommon(size_t Size)
SmallVector(const SmallVector &RHS)
static void uninitialized_move(It1 I, It1 E, It2 Dest)
const_iterator capacity_ptr() const
static size_t capacity_in_bytes(const SmallVector< T, N > &X)
SmallVectorImpl(unsigned N)
void set_size(size_type N)
SmallVectorTemplateBase(size_t Size)
static void destroy_range(T *, T *)
A ROSMessage will contain one or more ROSField(s). Each field is little more than a name / type pair.
uint64_t NextPowerOf2(uint64_t A)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46