Template Class List

Class Documentation

template<typename T>
class List

Simple DLL-safe resizable collection of objects.

Simple list type used to pass a collection of objects across the DLL boundary. This class is implemented using an array and, as such, removing items is not cheap as it requires us to move all items after it down one space.

Template Parameters

T – : Object type to store in the list

Public Functions

inline List()

Constructs a list with 0 elements.

inline List(size_t MinimumSize)

Constructs a list with the given number of elements.

Parameters

Size – size_t : Number of elements in the array

inline List(const List<T> &Other)

Copy constructor.

Parameters

Other – const List<T>&

inline List(List<T> &&Other)
inline List(std::initializer_list<T> List)

Constructs a list from an initializer_list.

Parameters

List – std::initializer_list : Elements to construct the list from

inline ~List()

Destructor.

Frees list memory.

inline T *Data()

Returns a pointer to the start of the list.

Returns

T*

inline const T *Data() const

Returns a const pointer to the start of the list.

Returns

const T*

inline List<T> &operator=(const List<T> &Other)

Copy assignment.

Parameters

Other – const List<T>&

Returns

List<T>&

inline T &operator[](size_t Index)

Returns an element at the given index of the list.

Parameters

Index – size_t : Element index to access

Returns

T& : List element

inline const T &operator[](size_t Index) const

Returns a const element at the given index of the list.

Parameters

Index – size_t : Element index to access

Returns

const T& : List element

inline void Append(const T &Item)

Appends an element to the end of the list.

Parameters

Item – const T&

inline void Append(T &&Item)

Appends an element to the end of the list.

Parameters

Item – T&&

inline void Insert(size_t Index, const T &Item)

Appends an element at the given index of the list.

Parameters
  • Index – size_t

  • Item – const T&

inline void Remove(size_t Index)

Removes an element to a specific index of the list.

Parameters

Index – size_t

inline void RemoveItem(const T &Item)

Removes the given element from the list.

Parameters

Item – const T& : Element to remove from the list

inline const size_t Size() const

Returns the number of elements in the array.

Returns

const size_t

inline void Clear()

Removes all elements in the list.

inline bool Contains(const T &Item) const

Checks if the list contains the given element.

Parameters

Item – const T& : Element to check if the list contains

Returns

bool

inline Array<T> ToArray() const

Returns a copy of this List as an Array.

Returns

Array<T>