Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::List< T, OwnershipPolicy > Class Template Reference

Intrusive doubly-linked list. More...

#include <list.h>

Inheritance diagram for roc::core::List< T, OwnershipPolicy >:
Collaboration diagram for roc::core::List< T, OwnershipPolicy >:

Public Types

typedef OwnershipPolicy< T >::Pointer Pointer
 Pointer type. More...
 

Public Member Functions

 List ()
 Initialize empty list. More...
 
 ~List ()
 Release ownership of containing objects. More...
 
size_t size () const
 Get number of elements in list. More...
 
bool is_empty () const
 Check if size is zero. More...
 
bool contains (const T &element)
 Check if element belongs to list. More...
 
Pointer front () const
 Get first list element. More...
 
Pointer back () const
 Get last list element. More...
 
Pointer nextof (T &element) const
 Get list element next to given one. More...
 
void push_front (T &element)
 Prepend element to list. More...
 
void push_back (T &element)
 Append element to list. More...
 
void insert_before (T &element, T &before)
 Insert element into list. More...
 
void remove (T &element)
 Remove element from list. More...
 

Detailed Description

template<class T, template< class TT > class OwnershipPolicy = RefCountedOwnership>
class roc::core::List< T, OwnershipPolicy >

Intrusive doubly-linked list.

Does not perform allocations. Provides O(1) size check, membership check, insertion, and removal.

Template Parameters
Tdefines object type, it should inherit ListNode.
OwnershipPolicydefines ownership policy which is used to acquire an element ownership when it's added to the list and release ownership when it's removed from the list.

Definition at line 35 of file list.h.

Member Typedef Documentation

◆ Pointer

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
typedef OwnershipPolicy<T>::Pointer roc::core::List< T, OwnershipPolicy >::Pointer

Pointer type.

Remarks
either raw or smart pointer depending on the ownership policy.

Definition at line 40 of file list.h.

Constructor & Destructor Documentation

◆ List()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
roc::core::List< T, OwnershipPolicy >::List ( )
inline

Initialize empty list.

Definition at line 43 of file list.h.

◆ ~List()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
roc::core::List< T, OwnershipPolicy >::~List ( )
inline

Release ownership of containing objects.

Definition at line 51 of file list.h.

Member Function Documentation

◆ back()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
Pointer roc::core::List< T, OwnershipPolicy >::back ( ) const
inline

Get last list element.

Returns
last element or NULL if list is empty.

Definition at line 97 of file list.h.

◆ contains()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
bool roc::core::List< T, OwnershipPolicy >::contains ( const T &  element)
inline

Check if element belongs to list.

Definition at line 79 of file list.h.

◆ front()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
Pointer roc::core::List< T, OwnershipPolicy >::front ( ) const
inline

Get first list element.

Returns
first element or NULL if list is empty.

Definition at line 87 of file list.h.

◆ insert_before()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
void roc::core::List< T, OwnershipPolicy >::insert_before ( T &  element,
T &  before 
)
inline

Insert element into list.

Remarks
  • inserts element before before
  • acquires ownership of element
Precondition
element should not be member of any list. before should be member of this list or NULL.

Definition at line 159 of file list.h.

◆ is_empty()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
bool roc::core::List< T, OwnershipPolicy >::is_empty ( ) const
inline

Check if size is zero.

Definition at line 74 of file list.h.

◆ nextof()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
Pointer roc::core::List< T, OwnershipPolicy >::nextof ( T &  element) const
inline

Get list element next to given one.

Returns
list element following element if element is not last, or NULL otherwise.
Precondition
element should be member of this list.

Definition at line 112 of file list.h.

◆ push_back()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
void roc::core::List< T, OwnershipPolicy >::push_back ( T &  element)
inline

Append element to list.

Remarks
  • appends element to list
  • acquires ownership of element
Precondition
element should not be member of any list.

Definition at line 146 of file list.h.

◆ push_front()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
void roc::core::List< T, OwnershipPolicy >::push_front ( T &  element)
inline

Prepend element to list.

Remarks
  • prepends element to list
  • acquires ownership of element
Precondition
element should not be member of any list.

Definition at line 130 of file list.h.

◆ remove()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
void roc::core::List< T, OwnershipPolicy >::remove ( T &  element)
inline

Remove element from list.

Remarks
  • removes element from list
  • releases ownership of element
Precondition
element should be member of this list.

Definition at line 171 of file list.h.

◆ size()

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
size_t roc::core::List< T, OwnershipPolicy >::size ( ) const
inline

Get number of elements in list.

Definition at line 69 of file list.h.


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