6 #include "Mountain/core.hpp" 27 using Iterator =
typename std::vector<T>::iterator;
28 using ConstIterator =
typename std::vector<T>::const_iterator;
29 using ReverseIterator =
typename std::vector<T>::reverse_iterator;
30 using ConstReverseIterator =
typename std::vector<T>::const_reverse_iterator;
41 explicit List(
size_t size);
47 explicit List(
size_t size,
const T& defaultValue);
53 explicit List(
size_t size,
const T* values);
59 template <
size_t Size>
60 explicit List(
const std::array<T, Size>& array);
65 explicit List(
const std::vector<T>& vector);
70 explicit List(std::vector<T>&& vector);
73 explicit List(Iterator b, Iterator e);
78 List(
const std::initializer_list<T>& values);
83 DEFAULT_COPY_MOVE_OPERATIONS(
List)
103 void Add(
const T& element);
108 void Add(
T&& element);
114 void AddRange(
const T* data,
size_t count);
119 void AddRange(
const std::initializer_list<T>& values);
124 void Fill(
const T& value);
129 void Fill(
T&& value);
135 template <
class... Args>
146 void Insert(
size_t index);
152 void Insert(
const T& element,
size_t index);
158 void Insert(
T&& element,
size_t index);
173 void RemoveAt(ConstIterator iterator);
193 void Iterate(
const std::function<
void(
T*)>& lambda);
200 void Iterate(
const std::function<
void(
const T*)>& lambda)
const;
209 bool_t
Exists(
const std::function<bool_t(
const T*)>& lambda)
const;
218 T*
Find(
const std::function<bool_t(
const T*)>& lambda);
227 const T*
Find(
const std::function<bool_t(
const T*)>& lambda)
const;
252 size_t FindPosition(
const std::function<bool_t(
const T*)>& lambda)
const;
259 T*
Find(
const std::function<bool_t(
const T*,
size_t)>& lambda);
261 void Sort(std::function<bool_t(
const T& left,
const T& right)> predicate = std::less());
294 typename std::vector<T>::reference
operator[](
size_t index);
303 typename std::vector<T>::const_reference
operator[](
size_t index)
const;
306 const T& Front()
const;
312 const T& Back()
const;
324 ConstIterator CBegin()
const;
327 ConstIterator CEnd()
const;
330 ReverseIterator RBegin();
333 ReverseIterator REnd();
336 ConstReverseIterator CrBegin()
const;
339 ConstReverseIterator CrEnd()
const;
349 ConstIterator begin()
const;
359 ConstIterator end()
const;
362 std::vector<T> m_Vector;
366 #include "Mountain/utils/list.inl" size_t FindPosition(const std::function< bool_t(const T *)> &lambda) const
Tries to find an element that fulfills the requirements provided in a lambda.
bool_t Exists(const std::function< bool_t(const T *)> &lambda) const
Checks if an element exists that fulfills the requirements provided in a lambda.
void RemoveAt(size_t index)
Removes an element from the list at a given index.
bool_t Contains(const T &element) const
Checks if the list contains a specified element.
T & Add()
Adds a default element to the end of the list (calls the default constructor of T) ...
void Fill(const T &value)
Fills the list with a specified value.
size_t GetCapacity() const
Gets the capacity of the list.
A dynamic array implementation. Wrapper around the std::vector class.
void Remove(const T &element)
Removes an element from the list (only removes the first occurence it finds)
List()=default
Creates an empty list with a capacity of 0.
std::vector< T >::reference operator[](size_t index)
Gets an element of the list at a specified index.
T * Find(const std::function< bool_t(const T *)> &lambda)
Tries to find an element that fulfills the requirements provided in a lambda.
void PopBack()
Removes the last element of the list.
void AddRange(const T *data, size_t count)
Adds a range of elements to the end of the list.
void RemoveRange(size_t start, size_t end)
Removes a range of elements from the list.
void Iterate(const std::function< void(T *)> &lambda)
Allows iteration over the list with a lambda.
void Clear()
Clears the list.
bool_t Empty() const
Returns whether the list is empty. This is equivalent to doing GetSize() == 0.
void Emplace(Args &&... args)
Constructs a new element and adds it to the end of the list.
bool_t Type
The type of the List<T>, refers to T.
void Insert(size_t index)
Inserts an element at the given position using the default constructor.
void Resize(size_t size)
Resizes a specified amount of elements in the list.
size_t GetSize() const
Gets the size of the list.
List< T * > FindAll(const std::function< bool_t(const T *)> &lambda)
Tries to find all elements that fulfill the requirements provided in a lambda.
~List()=default
Destroys the list.
T * GetData()
Gets the underlying pointer to the list.
Contains all declarations of the Mountain Framework.