CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Box.collection.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Box.hpp"
11
12namespace CeresEngine {
13
54
55 class Box::Iterable : public Box {
56 using super = Box;
57
58 public:
59 using super::Box;
60
61 CE_EXPLICIT(false) Iterable(const Box& other) : super(other) {}
62 CE_EXPLICIT(false) Iterable(Box&& other) noexcept : super(std::move(other)) {}
63
64 Iterable(const Iterable&) = default;
65 Iterable& operator=(const Iterable&) = default;
68
69 public: // Iteration
73
76
81
84 };
85
87 using super = Box;
88
89 public:
90 using super::Box;
91
92 CE_EXPLICIT(false) Array(const Box& other) : super(other) {}
93 CE_EXPLICIT(false) Array(Box&& other) noexcept : super(std::move(other)) {}
94
95 Array(const Array&) = default;
96 Array& operator=(const Array&) = default;
99
100 public: // Access
102 [[nodiscard]] TypeID getElementTypeID() const;
103
105 [[nodiscard]] Type getElementType() const { return Type(getElementTypeID()); }
106
108 [[nodiscard]] Box operator[](size_t position) const;
109
111 [[nodiscard]] Box at(size_t position) const;
112
114 [[nodiscard]] Box back() const;
115
117 [[nodiscard]] Box front() const;
118
119 public: // Size & capacity
122 [[nodiscard]] Box empty() const;
123
126 [[nodiscard]] size_t size() const;
127
137 void resize(size_t count) const;
138
147 void resize(size_t count, const Box& value) const;
148
156 void clear() const;
157
160 [[nodiscard]] Box capacity() const;
161
176 void reserve(size_t n) const;
177
178 public: // Insert & erase
186 Iterator insert(const Iterator& position, Box&& value) const;
187
189 Iterator insert(const Iterator& position, const Box& value) const;
190
200 Iterator insert(const Iterator& position, const Iterator& first, const Iterator& last) const;
201
214 Iterator erase(const Iterator& position) const;
215
224 void pushBack(Box&& value) const;
225
227 void pushBack(const Box& value) const;
228
233 void popBack() const;
234
242 void pushFront(Box&& value) const;
243
245 void pushFront(const Box& value) const;
246
250 void popFront() const;
251
252 public: // Iteration
256
259
263 [[nodiscard]] Iterator end() const;
264
267 };
268
269 class Box::Map : public Box {
270 using super = Box;
271
272 public:
273 using super::Box;
274
275 CE_EXPLICIT(false) Map(const Box& other) : super(other) {}
276 CE_EXPLICIT(false) Map(Box&& other) noexcept : super(std::move(other)) {}
277
278 Map(const Map&) = default;
279 Map& operator=(const Map&) = default;
280 Map(Map&&) noexcept = default;
281 Map& operator=(Map&&) noexcept = default;
282
283 public: // Access
285 [[nodiscard]] Box operator[](Box&& key) const;
286
289 [[nodiscard]] Box at(Box&& key) const;
290
291 public: // Size & capacity
294 [[nodiscard]] Box empty() const;
295
298 [[nodiscard]] size_t size() const;
299
307 void clear() const;
308
309 public: // Insert & erase
317 Iterator insert(Box&& key, Box&& value) const;
318
320 Iterator insert(Box&& key, const Box& value) const;
321
334 Iterator eraseIterator(const Iterator& position) const;
335
336 Iterator erase(Box&& key) const;
337
338 public: // Iteration
341 [[nodiscard]] Iterator begin() const;
342
344 [[nodiscard]] Iterator cbegin() const;
345
349 [[nodiscard]] Iterator end() const;
350
352 [[nodiscard]] Iterator cend() const;
353 };
354
355} // namespace CeresEngine
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
Definition Box.collection.hpp:86
Box empty() const
Checks if the container has no elements, i.e.
void popFront() const
Removes the first element of the container.
void pushBack(Box &&value) const
Appends the given element value to the end of the container.
void reserve(size_t n) const
Increase the capacity of the container (the total number of elements that the vector can hold without...
void pushFront(Box &&value) const
Appends the given element value to the front of the container.
Iterator insert(const Iterator &position, const Iterator &first, const Iterator &last) const
Inserts elements at the specified location in the container.
size_t size() const
Returns the number of elements in the container, i.e.
Iterator begin() const
Returns an iterator to the first element of the container.
Box capacity() const
Returns the number of elements that the container has currently allocated space for.
Box operator[](size_t position) const
void resize(size_t count, const Box &value) const
Resizes the container to contain count elements, does nothing if count == size().
Box at(size_t position) const
void pushBack(const Box &value) const
Array & operator=(const Array &)=default
void clear() const
Erases all elements from the container.
Iterator cbegin() const
Returns an iterator to the first element of the container.
Iterator insert(const Iterator &position, Box &&value) const
Inserts elements at the specified location in the container.
Iterator erase(const Iterator &position) const
Erases the specified elements from the container.
Iterator insert(const Iterator &position, const Box &value) const
void pushFront(const Box &value) const
Array(const Array &)=default
Iterator cend() const
Iterator end() const
Returns an iterator to the element following the last element of the container.
Array(Array &&) noexcept=default
void popBack() const
Removes the last element of the container.
void resize(size_t count) const
Resizes the container to contain count elements, does nothing if count == size().
Definition Box.collection.hpp:55
Iterator cbegin() const
Returns an iterator to the first element of the container.
Iterable(Iterable &&) noexcept=default
Iterable & operator=(const Iterable &)=default
Iterator end() const
Returns an iterator to the element following the last element of the container.
Iterable(const Iterable &)=default
Iterator begin() const
Returns an iterator to the first element of the container.
Box() noexcept
Creates a new variant holding an empty value.
Definition Box.collection.hpp:14
DifferenceType difference_type
Definition Box.collection.hpp:22
Box ValueType
Definition Box.collection.hpp:19
Iterator() noexcept=default
Creates a new empty MetaValue iterator.
~Iterator() noexcept=default
Destroys the iterator.
std::ptrdiff_t DifferenceType
Definition Box.collection.hpp:18
Box ReferenceType
Definition Box.collection.hpp:20
Definition Box.collection.hpp:269
Map(const Map &)=default
Map(Map &&) noexcept=default
Map & operator=(const Map &)=default
A value type that can hold any alongside it's type information.
Definition Box.hpp:40
void * data() noexcept
Returns pointer to decayed type.
Definition Box.hpp:260
friend class Type
Definition Box.hpp:128
Box() noexcept
Creates a new variant holding an empty value.
Represents a reflected C++ type. Can be used to get metadata from a C++ type.
Definition Type.hpp:32
Definition Application.hpp:19
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
constexpr CountAlgorithmFunctor count
Returns the number of elements matching an element.
Definition Count.hpp:82
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668