CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
AppendList< T > Class Template Reference

Single-linked list data container. More...

#include <cc/AppendList>

Public Types

using Item = T
 Item type.
 
using Transaction = AppendListTransaction<T>
 Transaction type
 
using const_iterator = AppendListIterator<T>
 Readonly value iterator.
 
using iterator = const_iterator
 Readonly value iterator.
 

Public Member Functions

 AppendList ()=default
 Create an empty list.
 
 AppendList (std::initializer_list< T > items)
 Construct with initial items.
 
 AppendList (const AppendList &other)
 Create a deep copy of other.
 
 AppendList (AppendList &&other)
 Take over other.
 
AppendListoperator= (AppendList &&other)
 Take over other.
 
AppendListoperator= (const AppendList &other)
 Create a deep copy of other.
 
 ~AppendList ()
 Destroy the list.
 
template<class... Args>
void emplaceBack (Args... args)
 Insert a new last item.
 
void pushBack (const T &item)
 Insert item as a new last item.
 
void append (const T &item)
 Insert item as a new last item.
 
const T & first () const
 Get constant reference to first item.
 
const T & last () const
 Get constant reference to last item.
 
Transaction transaction ()
 Begin a transaction.
 
const_iterator begin () const
 Return readonly iterator pointing to the first item (if any)
 
const_iterator end () const
 Return readonly iterator pointing behind the last item
 
bool isEmpty () const
 Tell if empty
 
long count () const
 Get number of items
 
long size () const
 Get number of items
 
 operator bool () const
 Check if this list is non-empty.
 
long operator+ () const
 Get number of items
 
void deplete ()
 Remove all items.
 

Detailed Description

template<class T>
class cc::AppendList< T >

Single-linked list data container.

Template Parameters
TItem type

AppendList is an as simple as it gets list data structure based on a single-linked list. The AppendList out-performs the List for short lists (smaller than 10 items) in both speed and memory consumption. Construction of an empty AppendList does not imply a memory allocation.

Member Typedef Documentation

◆ Item

template<class T >
using Item = T

Item type.

◆ Transaction

template<class T >
using Transaction = AppendListTransaction<T>

Transaction type

◆ const_iterator

template<class T >
using const_iterator = AppendListIterator<T>

Readonly value iterator.

◆ iterator

template<class T >
using iterator = const_iterator

Readonly value iterator.

Constructor & Destructor Documentation

◆ AppendList() [1/4]

template<class T >
AppendList ( )
default

Create an empty list.

◆ AppendList() [2/4]

template<class T >
AppendList ( std::initializer_list< T > items)

Construct with initial items.

◆ AppendList() [3/4]

template<class T >
AppendList ( const AppendList< T > & other)

Create a deep copy of other.

◆ AppendList() [4/4]

template<class T >
AppendList ( AppendList< T > && other)

Take over other.

◆ ~AppendList()

template<class T >
~AppendList ( )

Destroy the list.

Member Function Documentation

◆ operator=() [1/2]

template<class T >
AppendList & operator= ( AppendList< T > && other)

Take over other.

◆ operator=() [2/2]

template<class T >
AppendList & operator= ( const AppendList< T > & other)

Create a deep copy of other.

◆ emplaceBack()

template<class T >
template<class... Args>
void emplaceBack ( Args... args)

Insert a new last item.

Parameters
argsconstruction arguments

◆ pushBack()

template<class T >
void pushBack ( const T & item)

Insert item as a new last item.

◆ append()

template<class T >
void append ( const T & item)

Insert item as a new last item.

◆ first()

template<class T >
const T & first ( ) const

Get constant reference to first item.

◆ last()

template<class T >
const T & last ( ) const

Get constant reference to last item.

◆ transaction()

template<class T >
Transaction transaction ( )

Begin a transaction.

◆ begin()

template<class T >
const_iterator begin ( ) const

Return readonly iterator pointing to the first item (if any)

◆ end()

template<class T >
const_iterator end ( ) const

Return readonly iterator pointing behind the last item

◆ isEmpty()

template<class T >
bool isEmpty ( ) const

Tell if empty

◆ count()

template<class T >
long count ( ) const

Get number of items

◆ size()

template<class T >
long size ( ) const

Get number of items

◆ operator bool()

template<class T >
operator bool ( ) const
explicit

Check if this list is non-empty.

◆ operator+()

template<class T >
long operator+ ( ) const

Get number of items

◆ deplete()

template<class T >
void deplete ( )

Remove all items.