semf
|
LinkedList is an managed double linked list implementation. More...
#include <linkedlist.h>
Classes | |
class | ConstIterator |
Implementation of a bidirectional constant iterator for LinkedList . More... | |
class | Iterator |
Implementation of a bidirectional iterator for LinkedList . More... | |
class | Node |
Implements the previous() and next() functionality for every element in a list. More... | |
Public Member Functions | |
LinkedList () | |
Creates an empty List. More... | |
T & | front () |
Returns a reference to the first element in the list. More... | |
const T & | front () const |
Returns a reference to the first element in the list. More... | |
T & | back () |
Returns a reference to the last element in the list. More... | |
const T & | back () const |
Returns a reference to the last element in the list. More... | |
Iterator | begin () |
Returns an iterator pointing to the first element in the list. More... | |
ConstIterator | begin () const |
Returns an iterator pointing to the first element in the list. More... | |
ConstIterator | cbegin () const |
Returns an iterator pointing to the first element in the list. More... | |
Iterator | end () |
Returns an iterator referring to the past-the-end element in the list. More... | |
ConstIterator | end () const |
Returns an iterator referring to the past-the-end element in the list. More... | |
ConstIterator | cend () const |
Returns an iterator referring to the past-the-end element in the list. More... | |
bool | empty () const |
Returns whether the list is empty (i.e. whether its size is 0). More... | |
size_t | size () const |
Returns the number of elements in the list. More... | |
void | clear () |
Removes all elements from the list and leaving the list with a size of 0. More... | |
Iterator | insert (Iterator position, T &element) |
The list is extended by inserting new elements before the element at the specified position. More... | |
Iterator | erase (Iterator position) |
Removes a single element from the list. More... | |
Iterator | erase (Iterator first, Iterator last) |
Removes multiple elements from the list. More... | |
void | pushBack (T &element) |
Adds a new element to the end of the list, after its current last element. More... | |
void | pushFront (T &element) |
Adds a new element to the beginning of the list, before its current first element. More... | |
void | popBack () |
Removes the last element in the list, effectively reducing the list size by one. More... | |
void | popFront () |
Removes the first element in the list, effectively reducing the list size by one. More... | |
LinkedList< T > & | operator= (const LinkedList< T > &list) |
Assigns new contents to the list, replacing its current contents, and modifying its size accordingly. More... | |
LinkedList is an managed double linked list implementation.
It is similar to std::list, but works without dynamic storage allocation. Every element in the list has to inherit from LinkedList::Node
and in case has the information of the previous()
and the next()
node.
Like std::list LinkedList
also is a sequence of elements that allow constant time insert and erase operations anywhere within the sequence, and iteration in both directions.
List is implemented as doubly-linked lists. Double linked lists can store each of the elements they contain in different and unrelated storage locations. The ordering is kept internally by the association to each element of a link to the element preceding it and a link to the element following it.
T | class type inherits from LinkedList::Node |
Definition at line 42 of file linkedlist.h.
semf::LinkedList< T >::LinkedList |
Creates an empty List.
Definition at line 542 of file linkedlist.h.
T & semf::LinkedList< T >::back |
Returns a reference to the last element in the list.
Unlike member LinkedList::end
, which returns an iterator to this same element, this function returns a direct reference. Calling this function on a not existing element causes undefined behavior.
Definition at line 560 of file linkedlist.h.
const T & semf::LinkedList< T >::back |
Returns a reference to the last element in the list.
Unlike member LinkedList::end
, which returns an iterator to this same element, this function returns a direct reference. Calling this function on a not existing element causes undefined behavior.
Definition at line 566 of file linkedlist.h.
LinkedList< T >::Iterator semf::LinkedList< T >::begin |
Returns an iterator pointing to the first element in the list.
Definition at line 572 of file linkedlist.h.
LinkedList< T >::ConstIterator semf::LinkedList< T >::begin |
Returns an iterator pointing to the first element in the list.
Definition at line 578 of file linkedlist.h.
LinkedList< T >::ConstIterator semf::LinkedList< T >::cbegin |
Returns an iterator pointing to the first element in the list.
Definition at line 584 of file linkedlist.h.
LinkedList< T >::ConstIterator semf::LinkedList< T >::cend |
Returns an iterator referring to the past-the-end element in the list.
The past-the-end element is the theoretical element that would follow the last element in the list. It does not point to any element, and thus shall not be dereferenced. This function is often used in combination with LinkedList::begin to specify a range including all the elements in the range. If LinkedList is empty, this function returns the same as LinkedList::begin.
Definition at line 602 of file linkedlist.h.
void semf::LinkedList< T >::clear |
Removes all elements from the list and leaving the list with a size of 0.
Definition at line 620 of file linkedlist.h.
bool semf::LinkedList< T >::empty |
Returns whether the list is empty (i.e. whether its size is 0).
This function does not modify the list in any way. To clear the content of a list container, see LinkedList::clear.
true
if the list size is 0, false
otherwise. Definition at line 608 of file linkedlist.h.
LinkedList< T >::Iterator semf::LinkedList< T >::end |
Returns an iterator referring to the past-the-end element in the list.
The past-the-end element is the theoretical element that would follow the last element in the list. It does not point to any element, and thus shall not be dereferenced. This function is often used in combination with LinkedList::begin to specify a range including all the elements in the range. If LinkedList is empty, this function returns the same as LinkedList::begin.
Definition at line 590 of file linkedlist.h.
LinkedList< T >::ConstIterator semf::LinkedList< T >::end |
Returns an iterator referring to the past-the-end element in the list.
The past-the-end element is the theoretical element that would follow the last element in the list. It does not point to any element, and thus shall not be dereferenced. This function is often used in combination with LinkedList::begin to specify a range including all the elements in the range. If LinkedList is empty, this function returns the same as LinkedList::begin.
Definition at line 596 of file linkedlist.h.
LinkedList< T >::Iterator semf::LinkedList< T >::erase | ( | Iterator | first, |
Iterator | last | ||
) |
Removes multiple elements from the list.
This effectively reduces the list size by the number if erased elements.
position
points to an element inside this
. first | First element of a sequence to remove from the list. |
last | Last element of a sequence to remove from the list. |
Definition at line 679 of file linkedlist.h.
LinkedList< T >::Iterator semf::LinkedList< T >::erase | ( | Iterator | position | ) |
Removes a single element from the list.
This effectively reduces the list size by one.
this
. position | Position to erase from the list. Position has to have a exiting element. |
Definition at line 654 of file linkedlist.h.
T & semf::LinkedList< T >::front |
Returns a reference to the first element in the list.
Unlike member LinkedList::begin
, which returns an iterator to this same element, this function returns a direct reference. Calling this function on a not existing element causes undefined behavior.
Definition at line 548 of file linkedlist.h.
const T & semf::LinkedList< T >::front |
Returns a reference to the first element in the list.
Unlike member LinkedList::begin
, which returns an iterator to this same element, this function returns a direct reference. Calling this function on a not existing element causes undefined behavior.
Definition at line 554 of file linkedlist.h.
LinkedList< T >::Iterator semf::LinkedList< T >::insert | ( | Iterator | position, |
T & | element | ||
) |
The list is extended by inserting new elements before the element at the specified position.
position | Position in the list where the new element is inserted. |
element | Element to be inserted into the list. |
Definition at line 628 of file linkedlist.h.
LinkedList< T > & semf::LinkedList< T >::operator= | ( | const LinkedList< T > & | list | ) |
Assigns new contents to the list, replacing its current contents, and modifying its size accordingly.
list | A list object of the same type (i.e., with the same template parameter). |
Definition at line 755 of file linkedlist.h.
void semf::LinkedList< T >::popBack |
Removes the last element in the list, effectively reducing the list size by one.
Definition at line 725 of file linkedlist.h.
void semf::LinkedList< T >::popFront |
Removes the first element in the list, effectively reducing the list size by one.
Definition at line 741 of file linkedlist.h.
void semf::LinkedList< T >::pushBack | ( | T & | element | ) |
Adds a new element to the end of the list, after its current last element.
The content of element is moved into the list. This effectively increases the list size by one.
element | Element to add to the end of the list. |
Definition at line 689 of file linkedlist.h.
void semf::LinkedList< T >::pushFront | ( | T & | element | ) |
Adds a new element to the beginning of the list, before its current first element.
The content of element is moved into the list. This effectively increases the list size by one.
element | Element to add to the beginning of the list. |
Definition at line 708 of file linkedlist.h.
size_t semf::LinkedList< T >::size |
Returns the number of elements in the list.
Definition at line 614 of file linkedlist.h.