|
FMI Table
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 2 | Project Topic 7 |
|
Templated class that stores an array of elements in dynamic memory. More...
#include <List.hpp>
Public Member Functions | |
| List (const T *elements, unsigned elementsCount) | |
| Copies all elements in given array. | |
| List (unsigned length) | |
| Allocates memory for the given length. | |
| void | add (const T &element) |
| Adds an element. More... | |
| void | insertAt (const T &element, unsigned index) |
| Inserts element at given index. More... | |
| bool | removeAt (unsigned index) |
| Removes element at index. More... | |
| unsigned | findIndex (const T &element) const |
| Finds the index of element. More... | |
| bool | contain (const T &element) const |
| T & | operator[] (unsigned index) |
| Returns reference to element at index. | |
| const T & | operator[] (unsigned index) const |
| Returns constant reference to element at index. | |
| const T * | raw_data () const |
| Returns raw array of data. | |
| void | clear () |
| Removes all data. | |
| List< T > & | operator+= (const List< T > other) |
| Appends elements from other list. | |
| std::istream & | read (std::istream &istr) |
| Reads from stream. More... | |
| std::ostream & | write (std::ostream &ostr) const |
| Writes to stream. More... | |
| unsigned | get_length () const |
| Returns the length. More... | |
| unsigned | get_count () const |
| Returns the count. More... | |
| List & | operator= (const List &other) |
| List (const List &other) | |
| List (List &&other) | |
| List & | operator= (List &&other) |
Protected Member Functions | |
| void | resize () |
| void | free () |
| void | copyFrom (const List &other) |
Protected Attributes | |
| T * | elements |
| unsigned | length |
| unsigned | count |
Templated class that stores an array of elements in dynamic memory.
| void List< T >::add | ( | const T & | element | ) |
Adds an element.
Resizes internal array if there is no space for additional elements.
| bool List< T >::contain | ( | const T & | element | ) | const |
| unsigned List< T >::findIndex | ( | const T & | element | ) | const |
Finds the index of element.
| unsigned List< T >::get_count |
Returns the count.
Count is the amount of elements that are stored.
| unsigned List< T >::get_length |
Returns the length.
Length is the size of the underlying array (allocated memory).
| void List< T >::insertAt | ( | const T & | element, |
| unsigned | index | ||
| ) |
Inserts element at given index.
If index is after the last element, the element is just added. Otherwise all elements after the index are shifted right and element is put in place.
Resizes internal array if there is no space for additional elements.
| std::istream & List< T >::read | ( | std::istream & | istr | ) |
Reads from stream.
| istr | An input stream |
Directly reads bytes from stream (calls read() function). Any stored values are deleted and replaced with those from the stream.
| bool List< T >::removeAt | ( | unsigned | index | ) |
Removes element at index.
If index is after that of the last element, nothing is done and false is returned. Otherwise elements after index are shifted right and count is reduced.
| std::ostream & List< T >::write | ( | std::ostream & | ostr | ) | const |
Writes to stream.
| ostr | An output stream |
Directly writes bytes to stream (calls write() function).