20 template<
typename Type, ice::ContainerLogic Logic = ice::Constant_DefaultContainerLogic<Type>>
27 "Collection element type is not allowed with 'Trivial' logic!"
49 requires std::copy_constructible<Type>;
54 ) noexcept requires std::copy_constructible<Type>;
57 inline auto operator=(
Array const& other) noexcept ->
Array&
58 requires std::copy_constructible<Type>;
64 template<
typename Self>
69 constexpr void clear() noexcept;
72 template<typename ItemType = Type>
73 requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
76 template<
ice::
concepts::IterableContainer ContainerT>
77 requires (
ice::
concepts::CompatibleContainer<Type, ContainerT>)
78 inline
void push_back(ContainerT const& other) noexcept;
89 inline operator
ice::
Span<Type>() noexcept;
90 inline operator
ice::
Span<Type const>() const noexcept;
104 template<
typename Type, ice::ContainerLogic Logic>
115 template<
typename Type, ice::ContainerLogic Logic>
118 ,
_capacity{ ice::exchange(other._capacity, 0) }
119 ,
_count{ ice::exchange(other._count, 0) }
120 ,
_data{ ice::exchange(other._data,
nullptr) }
123 template<
typename Type, ice::ContainerLogic Logic>
125 requires std::copy_constructible<Type>
131 if (other._count > 0)
155 template<
typename Type, ice::ContainerLogic Logic>
159 )
noexcept requires std::copy_constructible<Type>
165 if (values.not_empty())
182 _count = values.size().u32();
186 template<
typename Type, ice::ContainerLogic Logic>
194 _capacity = ice::exchange(other._capacity, 0);
195 _data = ice::exchange(other._data,
nullptr);
196 _count = ice::exchange(other._count, 0);
201 template<
typename Type, ice::ContainerLogic Logic>
203 requires std::copy_constructible<Type>
208 this->
reserve(other.capacity());
210 if (other.size() > 0)
234 template<
typename Type, ice::ContainerLogic Logic>
242 if (new_capacity <
_count)
249 _count = new_capacity.u32();
253 if (new_capacity > 0)
277 template<
typename Type, ice::ContainerLogic Logic>
291 uninitialized_memory,
309 template<
typename Type, ice::ContainerLogic Logic>
319 template<
typename Type, ice::ContainerLogic Logic>
320 template<
typename ItemType>
321 requires std::convertible_to<ItemType, Type> && std::is_constructible_v<Type, ItemType>
335 _data[
_count] = Type{ ice::forward<ItemType>(item) };
341 template<
typename Type, ice::ContainerLogic Logic>
342 template<ice::concepts::IterableContainer ContainerT>
347 ice::ncount const required_capacity = other.size() + current_size;
350 this->
grow(required_capacity);
361 target_memory, other.begin(), other.end()
365 _count = required_capacity.u32();
368 template<
typename Type, ice::ContainerLogic Logic>
381 template <
typename Type, ice::ContainerLogic Logic>
384 if (
_count > 1 && index.is_valid())
391 template<
typename Type, ice::ContainerLogic Logic>
395 .location = self.data(),
401 template<
typename Type, ice::ContainerLogic Logic>
405 .location = self.data(),
406 .size = self.capacity(),
411 template<
typename Type, ice::ContainerLogic Logic>
417 template<
typename Type, ice::ContainerLogic Logic>
#define ICE_ASSERT_CORE(expression)
Definition assert_core.hxx:43
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:59
Definition container_concepts.hxx:12
ValueType< ContainerT > * ValuePtr
Definition container_concepts.hxx:155
constexpr auto min(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:60
arr_t< Size, T > arr
Definition array.hxx:178
SPDX-License-Identifier: MIT.
Definition array.hxx:12
auto mem_move_construct_n_at(ice::Memory memory, T *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:58
ContainerLogic
The logic implemented by a collectiont type when working with data. (Copying, Moving,...
Definition container_logic.hxx:13
@ Complex
The collection handles complex data types and properly implements copy and move semantics.
Definition container_logic.hxx:19
@ Trivial
The collection only handles plain old data and is allowed to memcopy values.
Definition container_logic.hxx:16
void mem_destruct_n_at(T *location, ice::u64 count) noexcept
Definition mem_initializers.hxx:113
auto data_view(ice::Array< Type, Logic > const &arr) noexcept -> ice::Data=delete
auto alloc(ice::usize size) noexcept -> ice::AllocResult
constexpr ice::ualign align_of
Definition mem_info.hxx:15
auto mem_copy_construct_it_at(ice::Memory memory, ItT begin, ItT end) noexcept -> T *
Definition mem_initializers.hxx:92
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
A simple container storing items in continuous memory.
Definition array.hxx:24
ice::u32 _capacity
Definition array.hxx:40
constexpr void set_capacity(SizeType new_capacity) noexcept
Definition array.hxx:235
constexpr auto data_view(this Array const &self) noexcept -> ice::Data
Definition array.hxx:392
ice::u32 _count
Definition array.hxx:41
Type ValueType
Definition array.hxx:30
constexpr void resize(SizeType new_size) noexcept
Definition array.hxx:278
auto operator=(Array &&other) noexcept -> Array &
Definition array.hxx:187
void push_back(ItemType &&item) noexcept
Definition array.hxx:322
ValueType * _data
Definition array.hxx:42
Type const ConstContainerValueType
Definition array.hxx:31
constexpr auto data(this Self &self) noexcept -> ice::container::ValuePtr< Self >
Definition array.hxx:65
constexpr auto memory_view(this Array &self) noexcept -> ice::Memory
Definition array.hxx:402
constexpr auto capacity() const noexcept -> SizeType
Definition array.hxx:66
ice::ncount SizeType
Definition array.hxx:36
constexpr void clear() noexcept
Definition array.hxx:310
Type const * ConstIterator
Definition array.hxx:34
ice::concepts::ContiguousContainerTag ContainerTag
Definition array.hxx:37
ice::Allocator * _allocator
Definition array.hxx:39
Type * Iterator
Definition array.hxx:32
void pop_back(ice::ncount count=1_count) noexcept
Definition array.hxx:369
~Array() noexcept
Definition array.hxx:105
void remove_at(ice::nindex index) noexcept
Definition array.hxx:382
std::reverse_iterator< Type const * > ConstReverseIterator
Definition array.hxx:35
Array(ice::Allocator &alloc) noexcept
Definition array.hxx:97
std::reverse_iterator< Type * > ReverseIterator
Definition array.hxx:33
constexpr auto size() const noexcept -> SizeType
Definition array.hxx:61
Definition mem_data.hxx:17
Definition mem_memory.hxx:13
A view into an array of objects laid out in contiguous memory.
Definition span.hxx:17
Definition container_concepts.hxx:56
Definition contiguous_container.hxx:14
constexpr auto end(this Self &&self) noexcept -> ice::container::Iterator< Self >
Definition contiguous_container.hxx:81
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
constexpr auto u32() const noexcept
Definition nvalue.hxx:113