14 template <
typename T,
typename TAllocator = Mallocator>
58 template <
typename,
typename>
119 return node == other.node;
123 return node != other.node;
130 template <
typename T,
typename TAllocator>
145 List(std::initializer_list<StorageType> list) {
146 for (
const StorageType& value : list) {
155 other.first = other.last =
nullptr;
171 return first ==
nullptr;
188 template <
typename U>
192 if (first ==
nullptr) {
201 template <
typename U>
205 if (last ==
nullptr) {
213 template <
typename U>
216 RawPtr<ListNode<T>> node = newNode(std::forward<U>(value), iter.node, iter.node->next);
217 if (iter.node == last) {
244 deleteNode(node.
get());
254 deleteNode(ptr.get());
258 first = last =
nullptr;
288 for (
auto& value : *
this) {
327 template <
typename TStream>
329 for (
const T& t : array) {
330 stream << t << std::endl;
336 template <
typename... TArgs>
344 node->~ListNode<T>();
346 TAllocator::deallocate(block);
Allocators used by containers.
#define SPH_ASSERT(x,...)
uint32_t Size
Integral type used to index arrays (by default).
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Simple non-owning wrapper of pointer.
Few non-standard type traits.
INLINE T & operator*() const
INLINE ListIterator operator++(int)
std::ptrdiff_t difference_type
bool operator==(const ListIterator &other) const
INLINE RawPtr< T > operator->() const
INLINE bool operator!() const
INLINE ListIterator & operator++()
INLINE ListIterator & operator--()
std::bidirectional_iterator_tag iterator_category
bool operator!=(const ListIterator &other) const
ListIterator(RawPtr< ListNode< T >> node)
INLINE ListIterator operator--(int)
INLINE const T & back() const
Returns the reference to the last element in the list.
List(std::initializer_list< StorageType > list)
Constructs the list given initializer_list of elements.
INLINE Size size() const
Returns the number of elements in the list.
void insert(const ListIterator< T > iter, U &&value)
List & operator=(List &&other)
Move operator.
ListIterator< const T > end() const
Returns a bidirectional iterator pointing to the one-past-last element of the list.
List(List &&other)
Move constructor.
ListIterator< T > end()
Returns a bidirectional iterator pointing to the one-past-last element of the list.
TAllocator & allocator()
Returns the interface to the allocator.
INLINE bool empty() const
Returns true if there are no elements in the list.
List clone() const
Creates a copy of the list.
INLINE T & front()
Returns the reference to the first element in the list.
ListIterator< const T > begin() const
Returns a bidirectional iterator pointing to the first element of the list.
friend TStream & operator<<(TStream &stream, const List &array)
Prints content of the list to stream. Stored values must have overloaded << operator.
void pushFront(U &&value)
Adds a new element to the beginning of the list.
void clear()
Removes all elements from the list.
const TAllocator & allocator() const
Returns the interface to the allocator.
INLINE T & back()
Returns the reference to the last element in the list.
INLINE const T & front() const
Returns the reference to the first element in the list.
List()
Constructs the list with no elements.
void pushBack(U &&value)
Adds a new element to the back of the list.
ListIterator< T > erase(const ListIterator< T > iter)
Removes an element given by the iterator.
ListIterator< T > begin()
Returns a bidirectional iterator pointing to the first element of the list.
Overload of std::swap for Sph::Array.
void swap(Sph::Array< T, TCounter > &ar1, Sph::Array< T, TCounter > &ar2)
RawPtr< ListNode > next
Next element in the list, can be nullptr.
StorageType value
Stored value.
RawPtr< ListNode > prev
Previous element in the list, can be nullptr.
ListNode(U &&value, RawPtr< ListNode > prev, RawPtr< ListNode > next)
typename WrapReferenceType< T >::Type StorageType
Object with deleted copy constructor and copy operator.