Apama  10.1.0.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
list_t Class Reference

A list class which implements many of the functions on std::vector. More...

#include <list_t.hpp>

Inherits sag_underlying_vector_t.

Classes

struct  _iterator
 Forward/reverse and const/non-const iterators are implemented using this class. More...
 

Public Types

typedef _iterator< data_t,
sag_underlying_data_t * > 
iterator
 The type of iterators over a mutable list. More...
 
typedef _iterator< const
data_t, const
sag_underlying_data_t * > 
const_iterator
 The type of iterators over a const list. More...
 

Public Member Functions

 list_t ()
 Construct an empty list. More...
 
 list_t (size_t n)
 Create a list with (at least) the specified capacity. More...
 
 ~list_t ()
 Free the underlying list. More...
 
list_toperator= (list_t &&other)
 Move assignment operator. More...
 
 list_t (list_t &&other)
 Move construction. More...
 
 list_t (std::initializer_list< data_t > l)
 Initialiser list construction. More...
 
void swap (list_t &&other)
 Swap the contents of this list with other. More...
 
list_t copy () const
 Return a deep copy of this list. More...
 
bool operator== (const list_t &other) const
 Returns true if this list is deep equals to other list. More...
 
bool operator!= (const list_t &other) const
 Returns false if this list is deep equals to other list. More...
 
iterator begin ()
 Forward iterator begin. More...
 
iterator end ()
 Forward iterator end. More...
 
const_iterator begin () const
 Forward const_iterator begin. More...
 
const_iterator end () const
 Forward const_iterator end. More...
 
const_iterator cbegin () const
 Forward const_iterator begin. More...
 
const_iterator cend () const
 Forward const_iterator end. More...
 
iterator rbegin ()
 Reverse iterator begin. More...
 
iterator rend ()
 Reverse iterator end. More...
 
const_iterator rbegin () const
 Reverse const_iterator begin. More...
 
const_iterator rend () const
 Reverse const_iterator end. More...
 
size_t size () const
 Return the number of items in this list. More...
 
bool empty () const
 Returns true if there are no items in this list. More...
 
const data_toperator[] (size_t n) const
 Returns a reference to the data_t at position n. More...
 
data_toperator[] (size_t n)
 Returns a reference to the data_t at position n. More...
 
const data_tfront () const
 Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty. More...
 
const data_tback () const
 Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty. More...
 
data_tfront ()
 Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty. More...
 
data_tback ()
 Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty. More...
 
void reserve (size_t n)
 Ensure the capacity is (at least) n. More...
 
void clear ()
 Clear the list and free the underlying data structure (capacity is now 0) More...
 
void push_back (data_t &&d)
 Add an item to the end of the list. More...
 
void pop_back ()
 Remove the last item in the list. More...
 

Detailed Description

A list class which implements many of the functions on std::vector.

We don't guarantee exact method-for-method compatibility with any of the std types.

This class gives access methods to an ordered list of data_t.

This is moveable, but not implicitly copyable. If you want to copy it use the .copy() method. If you want to move it use std::move().

The list is implemented as an array with amortized doubling. Modifying the contents will invalidate any iterators you have and any references that you have to the underlying structure.

Member Typedef Documentation

typedef _iterator<const data_t, const sag_underlying_data_t *> list_t::const_iterator

The type of iterators over a const list.

typedef _iterator<data_t, sag_underlying_data_t *> list_t::iterator

The type of iterators over a mutable list.

Constructor & Destructor Documentation

list_t::list_t ( )
inline

Construct an empty list.

list_t::list_t ( size_t  n)
explicit

Create a list with (at least) the specified capacity.

list_t::~list_t ( )
inline

Free the underlying list.

list_t::list_t ( list_t &&  other)
inline

Move construction.

Other will be left as the empty list.

list_t::list_t ( std::initializer_list< data_t l)
inline

Initialiser list construction.

Member Function Documentation

const data_t& list_t::back ( ) const
inline

Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty.

data_t& list_t::back ( )
inline

Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty.

iterator list_t::begin ( )
inline

Forward iterator begin.

const_iterator list_t::begin ( ) const
inline

Forward const_iterator begin.

const_iterator list_t::cbegin ( ) const
inline

Forward const_iterator begin.

const_iterator list_t::cend ( ) const
inline

Forward const_iterator end.

void list_t::clear ( )

Clear the list and free the underlying data structure (capacity is now 0)

list_t list_t::copy ( ) const
inline

Return a deep copy of this list.

bool list_t::empty ( ) const
inline

Returns true if there are no items in this list.

iterator list_t::end ( )
inline

Forward iterator end.

const_iterator list_t::end ( ) const
inline

Forward const_iterator end.

const data_t& list_t::front ( ) const
inline

Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty.

data_t& list_t::front ( )
inline

Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty.

bool list_t::operator!= ( const list_t other) const
inline

Returns false if this list is deep equals to other list.

list_t& list_t::operator= ( list_t &&  other)
inline

Move assignment operator.

Other will be left as the empty list and our previous contents freed.

bool list_t::operator== ( const list_t other) const

Returns true if this list is deep equals to other list.

const data_t& list_t::operator[] ( size_t  n) const

Returns a reference to the data_t at position n.

Throws std::runtime_error if n >= size()

data_t& list_t::operator[] ( size_t  n)

Returns a reference to the data_t at position n.

Throws std::runtime_error if n >= size()

void list_t::pop_back ( )

Remove the last item in the list.

void list_t::push_back ( data_t &&  d)

Add an item to the end of the list.

This is a move operation so the provided data_t will be left in an empty state. Use .copy() if you wish to copy into here or std::move otherwise.

iterator list_t::rbegin ( )
inline

Reverse iterator begin.

const_iterator list_t::rbegin ( ) const
inline

Reverse const_iterator begin.

iterator list_t::rend ( )
inline

Reverse iterator end.

const_iterator list_t::rend ( ) const
inline

Reverse const_iterator end.

void list_t::reserve ( size_t  n)
inline

Ensure the capacity is (at least) n.

size_t list_t::size ( ) const
inline

Return the number of items in this list.

void list_t::swap ( list_t &&  other)
inline

Swap the contents of this list with other.


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