Go to the documentation of this file.
17 #ifndef MOMO_INCLUDE_GUARD_STDISH_VECTOR
18 #define MOMO_INCLUDE_GUARD_STDISH_VECTOR
39 template<
typename TValue,
40 typename TAllocator = std::allocator<TValue>,
41 typename TArray = Array<TValue, MemManagerStd<TAllocator>>>
79 : mArray(MemManager(alloc))
84 : mArray(count, MemManager(alloc))
89 : mArray(count, value, MemManager(alloc))
93 template<
typename Iterator,
94 typename =
typename std::iterator_traits<Iterator>::iterator_category>
96 : mArray(first, last, MemManager(alloc))
101 : mArray(values, MemManager(alloc))
106 : mArray(std::move(right.mArray))
111 noexcept(std::is_empty<allocator_type>::value)
112 : mArray(pvCreateArray(
std::move(right), alloc))
117 : mArray(right.mArray)
122 : mArray(right.mArray, MemManager(alloc))
129 noexcept(std::is_empty<allocator_type>::value ||
130 std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value)
134 bool propagate = std::is_empty<allocator_type>::value ||
135 std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value;
137 mArray = pvCreateArray(std::move(right), alloc);
146 bool propagate = std::is_empty<allocator_type>::value ||
147 std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value;
149 mArray = Array(right.mArray, MemManager(alloc));
162 MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
164 mArray.Swap(right.mArray);
184 return mArray.GetBegin();
189 return mArray.GetBegin();
194 return mArray.GetEnd();
199 return mArray.GetEnd();
244 return mArray.GetItems();
249 return mArray.GetItems();
259 return std::allocator_traits<allocator_type>::max_size(
get_allocator());
264 return mArray.GetCount();
269 mArray.SetCount(
size);
274 mArray.SetCount(
size, value);
279 return mArray.IsEmpty();
289 return mArray.GetCapacity();
294 mArray.Reserve(count);
304 return mArray[index];
309 return mArray[index];
315 throw std::out_of_range(
"invalid vector subscript");
316 return mArray[index];
322 throw std::out_of_range(
"invalid vector subscript");
323 return mArray[index];
338 return mArray.GetBackItem();
343 return mArray.GetBackItem();
348 mArray.AddBack(std::move(value));
353 mArray.AddBack(value);
359 mArray.Insert(index, std::move(value));
366 mArray.Insert(index, value);
373 mArray.Insert(index, count, value);
377 template<
typename Iterator,
378 typename =
typename std::iterator_traits<Iterator>::iterator_category>
382 mArray.Insert(index, first, last);
389 mArray.Insert(index, values);
393 template<
typename... ValueArgs>
396 mArray.AddBackVar(std::forward<ValueArgs>(valueArgs)...);
400 template<
typename... ValueArgs>
404 mArray.InsertVar(index, std::forward<ValueArgs>(valueArgs)...);
415 return erase(where, where + 1);
425 template<
typename ValueArg>
428 auto valueFilter = [&valueArg] (
const value_type& value)
429 {
return value == valueArg; };
430 return cont.mArray.Remove(valueFilter);
433 template<
typename ValueFilter>
436 return cont.mArray.Remove(valueFilter);
444 template<
typename Iterator,
445 typename =
typename std::iterator_traits<Iterator>::iterator_category>
446 void assign(Iterator first, Iterator last)
451 void assign(std::initializer_list<value_type> values)
453 assign(values.begin(), values.end());
458 return mArray.IsEqual(right.mArray);
463 return !(*
this == right);
466 #ifdef MOMO_HAS_THREE_WAY_COMPARISON
467 auto operator<=>(
const vector& right)
const
468 requires requires (
const_reference ref) { std::tie(ref) <=> std::tie(ref); }
471 {
return std::tie(value1) <=> std::tie(value2); };
472 return std::lexicographical_compare_three_way(
begin(),
end(),
473 right.begin(), right.end(), comp);
478 return std::lexicographical_compare(
begin(),
end(), right.
begin(), right.
end());
483 return right < *
this;
488 return !(right < *
this);
493 return right <= *
this;
500 if (right.get_allocator() == alloc)
501 return std::move(right.mArray);
502 Array array(std::make_move_iterator(right.begin()),
503 std::make_move_iterator(right.end()), MemManager(alloc));
512 #ifdef MOMO_HAS_DEDUCTION_GUIDES
513 template<
typename Iterator,
514 typename Allocator = std::allocator<typename std::iterator_traits<Iterator>::value_type>>
515 vector(Iterator, Iterator, Allocator = Allocator())
528 template<
size_t tInternalCapacity,
typename TValue,
529 typename TAllocator = std::allocator<TValue>>
537 #endif // MOMO_INCLUDE_GUARD_STDISH_VECTOR
void shrink_to_fit()
Definition: vector.h:297
const_reference back() const
Definition: vector.h:341
friend void swap(vector &left, vector &right) noexcept
Definition: vector.h:167
reference front()
Definition: vector.h:326
vector(size_type count, const allocator_type &alloc=allocator_type())
Definition: vector.h:83
bool operator==(const vector &right) const
Definition: vector.h:456
vector(const allocator_type &alloc) noexcept
Definition: vector.h:78
reverse_iterator rbegin() noexcept
Definition: vector.h:207
const_reverse_iterator crend() const noexcept
Definition: vector.h:237
std::reverse_iterator< iterator > reverse_iterator
Definition: vector.h:70
const_reverse_iterator rend() const noexcept
Definition: vector.h:212
const_iterator cbegin() const noexcept
Definition: vector.h:222
Array nested_container_type
Definition: vector.h:54
reference back()
Definition: vector.h:336
const_reference front() const
Definition: vector.h:331
IteratorSelector::Iterator Iterator
Definition: Array.h:504
void push_back(value_type &&value)
Definition: vector.h:346
vector(std::initializer_list< value_type > values, const allocator_type &alloc=allocator_type())
Definition: vector.h:100
void assign(Iterator first, Iterator last)
Definition: vector.h:446
ptrdiff_t difference_type
Definition: vector.h:57
friend size_type erase_if(vector &cont, const ValueFilter &valueFilter)
Definition: vector.h:434
const value_type * data() const noexcept
Definition: vector.h:247
Array::Iterator iterator
Definition: vector.h:59
vector(Iterator first, Iterator last, const allocator_type &alloc=allocator_type())
Definition: vector.h:95
const_reference at(size_type index) const
Definition: vector.h:312
size_type max_size() const noexcept
Definition: vector.h:257
vector & operator=(std::initializer_list< value_type > values)
Definition: vector.h:154
const nested_container_type & get_nested_container() const noexcept
Definition: vector.h:172
size_type size() const noexcept
Definition: vector.h:262
const_reverse_iterator rbegin() const noexcept
Definition: vector.h:202
const_iterator end() const noexcept
Definition: vector.h:192
static UInt Dist(Iterator begin, Iterator end)
Definition: Utility.h:271
reference emplace_back(ValueArgs &&... valueArgs)
Definition: vector.h:394
momo::stdish::vector is similar to std::vector.
Definition: vector.h:43
vector(const vector &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: vector.h:121
const_reverse_iterator crbegin() const noexcept
Definition: vector.h:232
void resize(size_type size, const value_type &value)
Definition: vector.h:272
vector & operator=(vector &&right) noexcept(std::is_empty< allocator_type >::value||std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value)
Definition: vector.h:128
reference operator[](size_type index)
Definition: vector.h:307
void resize(size_type size)
Definition: vector.h:267
nested_container_type & get_nested_container() noexcept
Definition: vector.h:177
value_type * data() noexcept
Definition: vector.h:242
iterator insert(const_iterator where, size_type count, const value_type &value)
Definition: vector.h:370
value_type & reference
Definition: vector.h:62
vector(vector &&right, const momo::internal::Identity< allocator_type > &alloc) noexcept(std::is_empty< allocator_type >::value)
Definition: vector.h:110
void pop_back()
Definition: vector.h:408
iterator emplace(const_iterator where, ValueArgs &&... valueArgs)
Definition: vector.h:401
iterator insert(const_iterator where, Iterator first, Iterator last)
Definition: vector.h:379
size_t size_type
Definition: vector.h:56
EnableIf< true, Type > Identity
Definition: Utility.h:177
reverse_iterator rend() noexcept
Definition: vector.h:217
friend size_type erase(vector &cont, const ValueArg &valueArg)
Definition: vector.h:426
TMemManager MemManager
Definition: Array.h:196
void push_back(const value_type &value)
Definition: vector.h:351
void swap(vector &right) noexcept
Definition: vector.h:160
bool operator>=(const vector &right) const
Definition: vector.h:491
IteratorSelector::ConstIterator ConstIterator
Definition: Array.h:503
vector & operator=(const vector &right)
Definition: vector.h:142
bool operator!=(const vector &right) const
Definition: vector.h:461
iterator erase(const_iterator first, const_iterator last)
Definition: vector.h:418
size_type capacity() const noexcept
Definition: vector.h:287
bool operator<=(const vector &right) const
Definition: vector.h:486
iterator begin() noexcept
Definition: vector.h:187
void assign(std::initializer_list< value_type > values)
Definition: vector.h:451
void clear() noexcept
Definition: vector.h:282
void assign(size_type count, const value_type &value)
Definition: vector.h:439
vector() noexcept(noexcept(Array()))
Definition: vector.h:74
const_iterator cend() const noexcept
Definition: vector.h:227
Array::ConstIterator const_iterator
Definition: vector.h:60
const value_type & const_reference
Definition: vector.h:63
TAllocator allocator_type
Definition: vector.h:52
bool operator>(const vector &right) const
Definition: vector.h:481
Definition: ArrayUtility.h:299
bool operator<(const vector &right) const
Definition: vector.h:476
vector(size_type count, const value_type &value, const allocator_type &alloc=allocator_type())
Definition: vector.h:88
vector(vector &&right) noexcept
Definition: vector.h:105
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: vector.h:71
static Iterator Next(Iterator iter, UInt dist)
Definition: Utility.h:277
void reserve(size_type count)
Definition: vector.h:292
iterator erase(const_iterator where)
Definition: vector.h:413
allocator_type get_allocator() const noexcept
Definition: vector.h:252
const_iterator begin() const noexcept
Definition: vector.h:182
vector(const vector &right)
Definition: vector.h:116
value_type * pointer
Definition: vector.h:65
iterator insert(const_iterator where, std::initializer_list< value_type > values)
Definition: vector.h:386
TValue value_type
Definition: vector.h:51
const value_type * const_pointer
Definition: vector.h:66
iterator insert(const_iterator where, value_type &&value)
Definition: vector.h:356
Definition: Utility.h:254
#define MOMO_ASSERT(expr)
Definition: UserSettings.h:162
const_reference operator[](size_type index) const
Definition: vector.h:302
iterator insert(const_iterator where, const value_type &value)
Definition: vector.h:363
MOMO_NODISCARD bool empty() const noexcept
Definition: vector.h:277
#define MOMO_NODISCARD
Definition: UserSettings.h:192
reference at(size_type index)
Definition: vector.h:319
iterator end() noexcept
Definition: vector.h:197