FreeNOS
Data Structures | Public Member Functions | Private Attributes
List< T > Class Template Reference

Simple linked list template class. More...

#include <List.h>

Inheritance diagram for List< T >:
Sequence< T > Container Comparable< Sequence< T > >

Data Structures

class  Node
 Represents an item on the List. More...
 

Public Member Functions

 List ()
 Class constructor. More...
 
 List (const List< T > &lst)
 Copy constructor. More...
 
virtual ~List ()
 Class destructor. More...
 
void prepend (T t)
 Insert an item at the start of the list. More...
 
void append (T t)
 Insert an item at the end of the list. More...
 
virtual int remove (T t)
 Remove all items which are equal to the given item. More...
 
virtual int remove (Node *node)
 Removes the given node from the list. More...
 
virtual bool contains (const T t) const
 Check whether an element is on the List. More...
 
virtual void clear ()
 Clears the entire List. More...
 
Nodehead ()
 Get the first Node on the list. More...
 
const Nodehead () const
 Get the first Node on the List (read-only). More...
 
Nodetail ()
 Get the last Node on the list. More...
 
const Nodetail () const
 Get the last Node on the List (read-only). More...
 
first ()
 Get the first value in the list. More...
 
const T first () const
 Get the first value as constant. More...
 
last ()
 Get the last value on the list. More...
 
const T last () const
 Get the last value on the list as constant. More...
 
virtual const T * get (Size position) const
 Get a pointer to the item at the given position. More...
 
virtual const T & at (Size position) const
 Get a reference to the item at the given position. More...
 
virtual bool isEmpty () const
 Check if the List is empty. More...
 
Size size () const
 Get the size of the list. More...
 
Size count () const
 Get the number of items on the list. More...
 
Listoperator<< (T t)
 Append operator. More...
 
bool operator== (const List< T > &lst) const
 Comparison operator. More...
 
bool operator!= (const List< T > &lst) const
 Inequality operator. More...
 
- Public Member Functions inherited from Sequence< T >
virtual int insert (const T &item)
 Adds the given item to the Sequence, if possible. More...
 
virtual bool insert (Size position, const T &item)
 Inserts the given item at the given position. More...
 
virtual void fill (T value)
 Fill the Sequence with the given value. More...
 
virtual bool removeAt (Size position)
 Removes the item at the given position. More...
 
virtual int compareTo (const Sequence< T > &s) const
 Compare this Sequence to another Sequence. More...
 
virtual bool equals (const Sequence< T > &s) const
 Test if this Sequence is equal to an other Sequence. More...
 
const T & operator[] (int i) const
 Returns the item at the given position in the Sequence. More...
 
const T & operator[] (Size i) const
 Returns the item at the given position in the Sequence. More...
 
T & operator[] (int i)
 Returns the item at the given position in the Sequence. More...
 
T & operator[] (Size i)
 Returns the item at the given position in the Sequence. More...
 
- Public Member Functions inherited from Container
 Container ()
 Constructor. More...
 
virtual ~Container ()
 Destructor. More...
 
virtual bool reserve (Size size)
 Ensure that at least the given size is available. More...
 
virtual bool shrink (Size size)
 Shrink the container size by the given amount of items. More...
 
virtual Size squeeze ()
 Try to minimize the memory required in the Container. More...
 
virtual bool resize (Size size)
 Change the size of the Container. More...
 
- Public Member Functions inherited from Comparable< Sequence< T > >
virtual ~Comparable ()
 Class destructor. More...
 

Private Attributes

Nodem_head
 Head of the List. More...
 
Nodem_tail
 Tail of the list. More...
 
Size m_count
 Number of items currently in the List. More...
 

Detailed Description

template<class T>
class List< T >

Simple linked list template class.

Definition at line 36 of file List.h.

Constructor & Destructor Documentation

◆ List() [1/2]

template<class T >
List< T >::List ( )
inline

Class constructor.

Definition at line 69 of file List.h.

◆ List() [2/2]

template<class T >
List< T >::List ( const List< T > &  lst)
inline

Copy constructor.

Parameters
lstList instance to copy from

Definition at line 81 of file List.h.

◆ ~List()

template<class T >
virtual List< T >::~List ( )
inlinevirtual

Class destructor.

Definition at line 94 of file List.h.

Member Function Documentation

◆ append()

template<class T >
void List< T >::append ( t)
inline

◆ at()

template<class T >
virtual const T& List< T >::at ( Size  position) const
inlinevirtual

Get a reference to the item at the given position.

Parameters
positionIndex in the list.
Returns
Reference to the item at the given position.
Note
Assumes that the item is available.

Implements Sequence< T >.

Definition at line 365 of file List.h.

◆ clear()

template<class T >
virtual void List< T >::clear ( )
inlinevirtual

Clears the entire List.

Reimplemented from Sequence< T >.

Definition at line 232 of file List.h.

Referenced by Directory::clear(), IntelMP::discover(), IntelACPI::discover(), and Directory::~Directory().

◆ contains()

template<class T >
virtual bool List< T >::contains ( const T  t) const
inlinevirtual

Check whether an element is on the List.

Parameters
tThe element to find.
Returns
true if the element is on the List, false otherwise.

Reimplemented from Sequence< T >.

Definition at line 219 of file List.h.

Referenced by Associative< String, FileCache * >::compareTo(), HashTable< String, FileCache * >::keys(), List< ATADrive * >::operator!=(), List< ATADrive * >::operator==(), and ProcessShares::~ProcessShares().

◆ count()

template<class T >
Size List< T >::count ( ) const
inlinevirtual

◆ first() [1/2]

template<class T >
T List< T >::first ( )
inline

Get the first value in the list.

Returns
First value on the list.
Note
Assumes that the list is not empty.

Definition at line 292 of file List.h.

Referenced by ATAController::read().

◆ first() [2/2]

template<class T >
const T List< T >::first ( ) const
inline

Get the first value as constant.

Returns
First value on the list.
Note
Assumes that the list is not empty.

Definition at line 304 of file List.h.

◆ get()

template<class T >
virtual const T* List< T >::get ( Size  position) const
inlinevirtual

Get a pointer to the item at the given position.

Parameters
positionIndex in the list
Returns
Pointer to the item or ZERO if not available.

Implements Sequence< T >.

Definition at line 340 of file List.h.

◆ head() [1/2]

template<class T >
Node* List< T >::head ( )
inline

Get the first Node on the list.

Returns
First Node on the List.

Definition at line 254 of file List.h.

Referenced by FileSystemPath::FileSystemPath().

◆ head() [2/2]

template<class T >
const Node* List< T >::head ( ) const
inline

Get the first Node on the List (read-only).

Definition at line 262 of file List.h.

◆ isEmpty()

template<class T >
virtual bool List< T >::isEmpty ( ) const
inlinevirtual

Check if the List is empty.

Returns
true if empty, false if not.

Reimplemented from Container.

Definition at line 382 of file List.h.

Referenced by ATAController::read().

◆ last() [1/2]

template<class T >
T List< T >::last ( )
inline

Get the last value on the list.

Returns
Last value on the list.
Note
Assumes that the list is not empty.

Definition at line 316 of file List.h.

Referenced by ArgumentParser::parse().

◆ last() [2/2]

template<class T >
const T List< T >::last ( ) const
inline

Get the last value on the list as constant.

Returns
Last value on the list.
Note
Assumes that the list is not empty.

Definition at line 328 of file List.h.

◆ operator!=()

template<class T >
bool List< T >::operator!= ( const List< T > &  lst) const
inline

Inequality operator.

Definition at line 434 of file List.h.

◆ operator<<()

template<class T >
List& List< T >::operator<< ( t)
inline

Append operator.

Definition at line 410 of file List.h.

◆ operator==()

template<class T >
bool List< T >::operator== ( const List< T > &  lst) const
inline

Comparison operator.

Definition at line 419 of file List.h.

◆ prepend()

template<class T >
void List< T >::prepend ( t)
inline

Insert an item at the start of the list.

Parameters
tData item to te inserted.

Definition at line 111 of file List.h.

◆ remove() [1/2]

template<class T >
virtual int List< T >::remove ( Node node)
inlinevirtual

Removes the given node from the list.

Parameters
nodeThe Node to remove.
Returns
True on success, false otherwise

Definition at line 193 of file List.h.

◆ remove() [2/2]

template<class T >
virtual int List< T >::remove ( t)
inlinevirtual

Remove all items which are equal to the given item.

Parameters
tItem to remove.
Returns
Number of items removed from the list.

Reimplemented from Sequence< T >.

Definition at line 166 of file List.h.

Referenced by chdir(), List< ATADrive * >::remove(), and ProcessManager::unregisterInterruptNotify().

◆ size()

template<class T >
Size List< T >::size ( ) const
inlinevirtual

Get the size of the list.

Returns
Size of the list.

Implements Container.

Definition at line 392 of file List.h.

◆ tail() [1/2]

template<class T >
Node* List< T >::tail ( )
inline

Get the last Node on the list.

Returns
Last Node on the list.

Definition at line 272 of file List.h.

◆ tail() [2/2]

template<class T >
const Node* List< T >::tail ( ) const
inline

Get the last Node on the List (read-only).

Definition at line 280 of file List.h.

Field Documentation

◆ m_count

template<class T >
Size List< T >::m_count
private

◆ m_head

template<class T >
Node* List< T >::m_head
private

◆ m_tail

template<class T >
Node* List< T >::m_tail
private

The documentation for this class was generated from the following file: