Data Structures in C++
Public Member Functions
LinkedList< T > Class Template Reference

Doubly-linked list implementation with dynamic memory allocation. More...

#include <LinkedList.hpp>

Inheritance diagram for LinkedList< T >:
Collaboration diagram for LinkedList< T >:

Public Member Functions

 LinkedList ()
 
 LinkedList (T data[])
 create the structure and populate it with the data from the array More...
 
string getName ()
 Provides the name of the data structure as a string representation. More...
 
virtual void insert (T val)
 Insert an element at the end of the list. More...
 
virtual void insert (T val, int index)
 Insert an element at the specified position in the list. More...
 
virtual T remove (int index)
 Remove an element from the list. More...
 
virtual T get (int index)
 Get the element at the specified position in the list, without removing it. More...
 
Iterator< T > iterator ()
 Creates an Iterator, an object that allows the sequential access of values in a Linked List without the search overhead. More...
 
- Public Member Functions inherited from ProtectedLinkedList< T >
 ProtectedLinkedList ()
 
 ~ProtectedLinkedList ()
 
int getSize ()
 Outputs the number of elements stored in the structure. More...
 
bool isEmpty ()
 Check whether the structure is empty. More...
 
bool isFull ()
 Check whether the structure is full. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ProtectedLinkedList< T >
Node< T > * getNode (int index)
 
 ProtectedLinkedList (const T data[])
 create the structure and populate it with the data from the array More...
 
Node< T > * getFirst () const
 
Node< T > * getLast () const
 

Detailed Description

template<class T>
class LinkedList< T >

Doubly-linked list implementation with dynamic memory allocation.

Author
Douglas De Rizzo Meneghetti (dougl.nosp@m.asri.nosp@m.zzom@.nosp@m.gmai.nosp@m.l.com)
Date
2017-6-8Doubly-linked list implementation with dynamic memory allocation. This class exposes many of the protected methods from ProtectedLinkedList, where all list-related functionality is actually implemented.
Template Parameters
TThe type of object the data structure will contain

Definition at line 17 of file LinkedList.hpp.

Constructor & Destructor Documentation

◆ LinkedList() [1/2]

template<class T>
LinkedList< T >::LinkedList ( )
inlineexplicit

Definition at line 19 of file LinkedList.hpp.

19  {
20  }

◆ LinkedList() [2/2]

template<class T>
LinkedList< T >::LinkedList ( data[])
inlineexplicit

create the structure and populate it with the data from the array

Parameters
dataan array with data with which the structure will be initialized

Definition at line 24 of file LinkedList.hpp.

24  : ProtectedLinkedList<T>(data) {
25  }
Doubly-linked list implementation with dynamic memory allocation.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf =======
>>>>>>> master

Member Function Documentation

◆ get()

template<class T>
virtual T LinkedList< T >::get ( int  index)
inlinevirtual

Get the element at the specified position in the list, without removing it.

Parameters
indexindex of the desired element

Reimplemented from ProtectedLinkedList< T >.

Reimplemented in OrderedList< T >.

Definition at line 51 of file LinkedList.hpp.

51  {
52  return ProtectedLinkedList<T>::get(index);
53  }
virtual T get(const int index)
Get the element at the specified position in the list, without removing.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ getName()

template<class T>
string LinkedList< T >::getName ( )
inlinevirtual

Provides the name of the data structure as a string representation.

Returns
name of the data structure

Reimplemented from ProtectedLinkedList< T >.

Reimplemented in OrderedList< T >.

Definition at line 27 of file LinkedList.hpp.

27 { return "Linked List"; }

◆ insert() [1/2]

template<class T>
virtual void LinkedList< T >::insert ( val)
inlinevirtual

Insert an element at the end of the list.

Parameters
valthe value to be inserted

Reimplemented from ProtectedLinkedList< T >.

Reimplemented in OrderedList< T >.

Definition at line 31 of file LinkedList.hpp.

31  {
33  }
virtual void insert(const T val)
Insert an element at the end of the list.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ insert() [2/2]

template<class T>
virtual void LinkedList< T >::insert ( val,
int  index 
)
inlinevirtual

Insert an element at the specified position in the list.

Parameters
valthe value to be inserted
indexposition of the list that the element will be inserted on

Reimplemented from ProtectedLinkedList< T >.

Reimplemented in OrderedList< T >.

Definition at line 38 of file LinkedList.hpp.

38  {
40  }
virtual void insert(const T val)
Insert an element at the end of the list.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master

◆ iterator()

template<class T>
Iterator<T> LinkedList< T >::iterator ( )
inlinevirtual

Creates an Iterator, an object that allows the sequential access of values in a Linked List without the search overhead.

Returns
an Iterator starting from the first node of the list

Reimplemented from ProtectedLinkedList< T >.

Definition at line 58 of file LinkedList.hpp.

58  {
60  }
Node< T > * getFirst() const
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Object that provides iterative powers to classes composed of Node.
Definition: Iterator.hpp:14
Here is the call graph for this function:
Here is the caller graph for this function:
=======
Object that provides iterative powers to classes composed of Node.
Definition: Iterator.hpp:13
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
Object that provides iterative powers to classes composed of Node.
Definition: Iterator.hpp:13
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf =======
Iterator
Object that provides iterative powers to classes composed of Node.
Definition: Iterator.hpp:13
>>>>>>> master

◆ remove()

template<class T>
virtual T LinkedList< T >::remove ( int  index)
inlinevirtual

Remove an element from the list.

Parameters
indexposition of the element to be removed
Returns
the element that is being removed

Reimplemented from ProtectedLinkedList< T >.

Reimplemented in OrderedList< T >.

Definition at line 45 of file LinkedList.hpp.

45  {
46  return ProtectedLinkedList<T>::remove(index);
47  }
virtual T remove(const int index)
Remove an element from the list.
<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD
Here is the call graph for this function:
=======
>>>>>>> 36f9b37... fixed dependency of ProtectedLinkedList to Iterator =======
>>>>>>> bded2143692dca559ffcc9e7202d9eb5fbfc45bf ======= >>>>>>> master
The documentation for this class was generated from the following file: