20 template<
typename Type, ice::ContainerLogic Logic = ice::Constant_DefaultContainerLogic<Type>>
27 "Collection element type is not allowed with 'Trivial' logic!"
48 requires std::copy_constructible<Type>;
58 constexpr void clear() noexcept;
61 template<typename ItemType = Type>
62 requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
63 constexpr
void push_front(ItemType&& item) noexcept;
65 template<typename ItemType = Type>
66 requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
67 constexpr
void push_back(ItemType&& item) noexcept;
70 template<
ice::
concepts::ContiguousContainer ContainerT>
71 requires (
ice::
concepts::CompatibleContainer<Type, ContainerT>)
72 constexpr
void push_front(ContainerT const& other) noexcept;
75 template<
ice::
concepts::ContiguousContainer ContainerT>
76 requires (
ice::
concepts::CompatibleContainer<Type, ContainerT>)
77 constexpr
void push_back(ContainerT const& other) noexcept;
83 template<typename Self>
84 constexpr auto
front(this Self&& self) noexcept ->
ice::
container::ValueRef<Self>;
85 template<typename Self>
86 constexpr auto
back(this Self&& self) noexcept ->
ice::
container::ValueRef<Self>;
88 template<typename Self, typename Fn>
89 constexpr
void for_each(this Self&& self, Fn&& fn) noexcept;
90 template<typename Self, typename Fn>
93 template<typename Self>
100 inline auto operator=(
Queue&& other) noexcept ->
Queue&;
101 inline auto operator=(
Queue const& other) noexcept ->
Queue&
102 requires std::copy_constructible<Type>;
104 template<typename Self>
105 constexpr auto operator[](
113 template<
typename Type>
116 ice::u32 const raw_end_idx =
queue._offset + destroy_count.u32();
121 if (start_idx > end_idx)
132 template<
typename Type>
136 ice::nindex const start_idx = (raw_end_idx - destroy_count.u32()) %
queue._capacity;
140 if (start_idx > end_idx)
151 template<
typename Type>
165 template<
typename Type>
183 template<
typename Type>
199 .size = head_end_offset,
209 .location =
queue._data,
210 .size = tail_end_offset,
218 template<
typename Type, ice::ContainerLogic Logic>
228 template<
typename Type, ice::ContainerLogic Logic>
231 ,
_capacity{ ice::exchange(other._capacity, 0) }
232 ,
_count{ ice::exchange(other._count, 0) }
233 ,
_offset{ ice::exchange(other._offset, 0) }
234 ,
_data{ ice::exchange(other._data,
nullptr) }
238 template<
typename Type, ice::ContainerLogic Logic>
246 if (other._count > 0)
263 template<
typename Type, ice::ContainerLogic Logic>
286 template<
typename Type, ice::ContainerLogic Logic>
293 _capacity = ice::exchange(other._capacity, 0);
294 _count = ice::exchange(other._count, 0);
295 _offset = ice::exchange(other._offset, 0);
296 _data = ice::exchange(other._data,
nullptr);
301 template<
typename Type, ice::ContainerLogic Logic>
303 requires std::copy_constructible<Type>
310 if (other._count > 0)
327 template<
typename Type, ice::ContainerLogic Logic>
335 if (new_capacity <
_count)
342 _count = new_capacity.u32();
345 Type* new_data =
nullptr;
346 if (new_capacity > 0)
360 new_data =
reinterpret_cast<Type*
>(new_buffer.
memory);
369 template<
typename Type, ice::ContainerLogic Logic>
384 ice::nindex const wrapped_end_idx = missing_items - (end_idx - start_idx);
389 .location =
_data + start_idx,
393 (end_idx - start_idx)
413 template<
typename Type, ice::ContainerLogic Logic>
425 template<
typename Type, ice::ContainerLogic Logic>
426 template<
typename ItemType>
requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
445 ice::forward<Type>(item)
456 template<
typename Type, ice::ContainerLogic Logic>
457 template<
typename ItemType>
requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
470 ice::forward<Type>(item)
475 _data[item_idx] = Type{ item };
481 template<
typename Type, ice::ContainerLogic Logic>
501 template<
typename Type, ice::ContainerLogic Logic>
520 template<
typename Type, ice::ContainerLogic Logic>
521 template<ice::concepts::ContiguousContainer ContainerT>
529 this->
grow(required_capacity);
536 ice::ncount const head_space = end_idx - start_idx;
538 ice::ncount const tail_space = other_count - head_space;
544 .location =
_data + start_idx,
557 other.data() + head_space,
565 .location =
_data + start_idx,
570 .location = other.data(),
582 .location = other.data() + head_space,
589 _count += other.size().u32();
592 template<
typename Type, ice::ContainerLogic Logic>
593 template<
typename Self>
596 return self._data[self._offset];
599 template<
typename Type, ice::ContainerLogic Logic>
600 template<
typename Self>
603 return self._data[((self._offset + self._count) - 1) % self._capacity];
606 template<
typename Type, ice::ContainerLogic Logic>
607 template<
typename Self,
typename Fn>
610 if (self._count == 0)
615 ice::u32 const first_part =
ice::min(self._offset + self._count, self._capacity);
616 ice::u32 const second_part = (self._offset + self._count) - first_part;
618 for (
ice::u32 idx = self._offset; idx < first_part; ++idx)
620 ice::forward<Fn>(fn)(self._data[idx]);
623 for (
ice::u32 idx = 0; idx < second_part; ++idx)
625 ice::forward<Fn>(fn)(self._data[idx]);
629 template<
typename Type, ice::ContainerLogic Logic>
630 template<
typename Self,
typename Fn>
633 if (self._count == 0)
638 ice::u32 const first_part =
ice::min(self._offset + self._count, self._capacity);
639 ice::u32 const second_part = (self._offset + self._count) - first_part;
643 for (
ice::u32 idx = second_part - 1; idx > 0; --idx)
645 ice::forward<Fn>(fn)(self._data[idx]);
648 ice::forward<Fn>(fn)(self._data[0]);
651 for (
ice::u32 idx = first_part - 1; idx > self._offset; --idx)
653 ice::forward<Fn>(fn)(self._data[idx]);
656 ice::forward<Fn>(fn)(self._data[self._offset]);
659 template<
typename Type, ice::ContainerLogic Logic>
660 template<
typename Self>
670 ice::ncount const second_part = (self._offset + taken_items) - first_part;
671 ice::ncount const first_part_count = first_part - self._offset;
684 self.pop_front(taken_items);
688 template<
typename Type, ice::ContainerLogic Logic>
692 .location = self._data,
693 .size = self.capacity(),
698 template<
typename Type, ice::ContainerLogic Logic>
699 template<
typename Self>
704 return self._data[(idx + self._offset) % self._capacity];
A concept that ensures only types that can be trivially copyable can be 'forced' to use trifial Logic...
Definition container_logic.hxx:25
Definition container_concepts.hxx:175
Definition container_concepts.hxx:12
Definition associative_container.hxx:8
ValueType< ContainerT > & ValueRef
Definition container_concepts.hxx:149
constexpr auto min(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:60
void copy_items_to_new_location(ice::Memory dest, ice::Queue< Type, ContainerLogic::Complex > const &queue) noexcept
Definition queue.hxx:152
void move_items_to_new_location(ice::Memory dest, ice::Queue< Type, ContainerLogic::Complex > &queue) noexcept
Definition queue.hxx:166
void destroy_tail_items(ice::Queue< Type, ContainerLogic::Complex > &queue, ice::ncount destroy_count) noexcept
Definition queue.hxx:133
void destroy_head_items(ice::Queue< Type, ContainerLogic::Complex > &queue, ice::ncount destroy_count) noexcept
Definition queue.hxx:114
void copy_memory_to_new_location(ice::Memory dest, ice::Queue< Type, ContainerLogic::Trivial > const &queue) noexcept
Definition queue.hxx:184
SPDX-License-Identifier: MIT.
Definition array.hxx:12
auto mem_move_n_to(T *target_objects, T *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:70
constexpr ice::usize size_of
Definition mem_info.hxx:12
auto mem_move_construct_n_at(ice::Memory memory, T *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:58
@ Complex
The collection handles complex data types and properly implements copy and move semantics.
Definition container_logic.hxx:19
void mem_destruct_n_at(T *location, ice::u64 count) noexcept
Definition mem_initializers.hxx:113
auto alloc(ice::usize size) noexcept -> ice::AllocResult
constexpr ice::ualign align_of
Definition mem_info.hxx:15
auto mem_default_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:46
auto ptr_add(void *pointer, ice::usize offset) noexcept -> void *
Definition mem_arithmetic.hxx:34
auto mem_copy_construct_n_at(ice::Memory memory, T const *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:80
constexpr auto count(T const (&)[Size]) noexcept -> ice::u32
Definition base.hxx:43
std::uint32_t u32
Definition types.hxx:26
constexpr ice::meminfo meminfo_of
Definition mem_info.hxx:18
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition mem_types.hxx:25
auto mem_construct_at(void *memory_ptr, Args &&... args) noexcept -> T *
Definition mem_initializers.hxx:12
auto memcpy(void *dest, void const *source, ice::usize size) noexcept -> void *
void * memory
Definition mem.hxx:45
Definition mem_data.hxx:17
Definition mem_memory.hxx:13
A double ended queue, build on a circular buffer.
Definition queue.hxx:24
ice::ncount SizeType
Definition queue.hxx:36
constexpr auto take_front(this Self &&self, ice::Span< Type > out_values) noexcept -> ice::ncount
Definition queue.hxx:661
constexpr void for_each_reverse(this Self &&self, Fn &&fn) noexcept
Definition queue.hxx:631
ice::u32 _count
Definition queue.hxx:41
std::reverse_iterator< Type const * > ConstReverseIterator
Definition queue.hxx:35
auto operator=(Queue &&other) noexcept -> Queue &
Definition queue.hxx:287
Type * Iterator
Definition queue.hxx:32
Type const * ConstIterator
Definition queue.hxx:34
ice::u32 _capacity
Definition queue.hxx:40
~Queue() noexcept
Definition queue.hxx:264
constexpr auto back(this Self &&self) noexcept -> ice::container::ValueRef< Self >
Definition queue.hxx:601
constexpr void for_each(this Self &&self, Fn &&fn) noexcept
Definition queue.hxx:608
constexpr void clear() noexcept
Definition queue.hxx:414
constexpr void set_capacity(ice::ncount new_capacity) noexcept
Definition queue.hxx:328
Queue(ice::Allocator &alloc) noexcept
Definition queue.hxx:219
constexpr auto capacity() const noexcept -> ice::ncount
Definition queue.hxx:55
ice::u32 _offset
Definition queue.hxx:42
constexpr void pop_front(ice::ncount count=1_count) noexcept
Definition queue.hxx:482
ice::concepts::ContiguousContainerTag ContainerTag
Definition queue.hxx:37
constexpr auto front(this Self &&self) noexcept -> ice::container::ValueRef< Self >
Definition queue.hxx:594
constexpr void pop_back(ice::ncount count=1_count) noexcept
Definition queue.hxx:502
std::reverse_iterator< Type * > ReverseIterator
Definition queue.hxx:33
constexpr void resize(ice::ncount new_size) noexcept
Definition queue.hxx:370
Type * _data
Definition queue.hxx:43
Type ValueType
Definition queue.hxx:30
constexpr auto memory_view(this Queue &self) noexcept -> ice::Memory
Definition queue.hxx:689
ice::Allocator * _allocator
Definition queue.hxx:39
constexpr auto size() const noexcept -> ice::ncount
Definition queue.hxx:52
constexpr auto operator[](this Self &&self, ice::nindex idx) noexcept -> ice::container::ValueRef< Self >
Definition queue.hxx:700
Type const ConstContainerValueType
Definition queue.hxx:31
constexpr void push_back(ItemType &&item) noexcept
Definition queue.hxx:458
constexpr void push_front(ItemType &&item) noexcept
Definition queue.hxx:427
A view into an array of objects laid out in contiguous memory.
Definition span.hxx:17
Definition container_concepts.hxx:56
Definition basic_container.hxx:11
Definition resizable_container.hxx:11
constexpr void reserve(this Self &self, ice::ncount min_capacity) noexcept
Definition resizable_container.hxx:25
constexpr void grow(this Self &self, ice::ncount min_capacity=ice::ncount_none) noexcept
Definition resizable_container.hxx:34
Represents a unsigned size value on the given platform.
Definition mem_size_types.hxx:26
std::size_t base_type
Definition mem_size_types.hxx:28