Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TDeque< T > Class Template Reference

Counted deque having additional methods and operators for ease of usage. More...

#include <TDeque.h>

Inheritance diagram for sf::TDeque< T >:
Collaboration diagram for sf::TDeque< T >:

Public Types

typedef std::deque< T > base_type
 Base type of this template .
 
typedef base_type::size_type size_type
 Size type of this template.
 
typedef base_type::value_type value_type
 Value type contained by this deque template.
 

Public Member Functions

 TDeque ()=default
 Default constructor.
 
template<typename InputIterator >
 TDeque (InputIterator first, InputIterator last)
 Initializing constructor using an iterator.
 
 TDeque (std::initializer_list< value_type > list)
 Initializing constructor using list like:
TDeque que{1,2,3,4,5,6,7}
 
 TDeque (const base_type &sv)
 Copy constructor for base type.
 
 TDeque (size_type sz)
 Initializing constructor.
 
size_type add (const T &)
 Adds item at the end of the deque.
 
size_type add (const TDeque< T > &)
 Adds the deques items at the end of the deque.
 
bool addAt (const T &t, size_type index)
 Adds an item at index position.
 
bool detach (const T &t)
 Removes specific item from the list by instance.
 
bool detachAt (size_type index)
 Removes specific item from the list by index.
 
bool isEmpty () const
 Returns true when empty false otherwise.
 
void flush ()
 Removes all entries from the deque.
 
void flush (size_type stop, size_type start=0)
 Removes specific range of entries from the deque.
 
size_type find (const T &) const
 Finds an entry by instance in the deque.
 
size_type count () const
 Returns the amount of entries in the deque.
 
T & get (size_type i)
 Gets entry from index position.
 
const T & get (size_type i) const
 Const version of getting entry from index position.
 
base_type getBase ()
 Returns the base type to access it methods explicitly.
 
base_type getBase () const
 Returns the constant const base type.
 
T & operator[] (size_type i)
 Array operator.
 
const T & operator[] (size_type i) const
 Const array operator.
 
std::ostream & write (std::ostream &os, bool inc_hex) const
 

Static Public Attributes

static const size_t npos = static_cast<size_type>(-1)
 Value returned by various member functions when they fail.
 

Detailed Description

template<typename T>
class sf::TDeque< T >

Counted deque having additional methods and operators for ease of usage.

This template class extends the std::deque template with easier to use methods for adding finding entries and an array operator.

Template Parameters
TType contained by the deque.

Member Typedef Documentation

◆ base_type

template<typename T >
typedef std::deque<T> sf::TDeque< T >::base_type

Base type of this template .

◆ size_type

template<typename T >
typedef base_type::size_type sf::TDeque< T >::size_type

Size type of this template.

◆ value_type

template<typename T >
typedef base_type::value_type sf::TDeque< T >::value_type

Value type contained by this deque template.

Constructor & Destructor Documentation

◆ TDeque() [1/5]

template<typename T >
sf::TDeque< T >::TDeque ( )
default

Default constructor.

◆ TDeque() [2/5]

template<typename T >
template<typename InputIterator >
sf::TDeque< T >::TDeque ( InputIterator  first,
InputIterator  last 
)
inline

Initializing constructor using an iterator.

◆ TDeque() [3/5]

template<typename T >
sf::TDeque< T >::TDeque ( std::initializer_list< value_type list)
inline

Initializing constructor using list like:
TDeque que{1,2,3,4,5,6,7}

◆ TDeque() [4/5]

template<typename T >
sf::TDeque< T >::TDeque ( const base_type sv)
inlineexplicit

Copy constructor for base type.

◆ TDeque() [5/5]

template<typename T >
sf::TDeque< T >::TDeque ( size_type  sz)
inlineexplicit

Initializing constructor.

Parameters
szSize of the deque.

Member Function Documentation

◆ add() [1/2]

template<typename T >
TDeque< T >::size_type sf::TDeque< T >::add ( const T &  t)

Adds item at the end of the deque.

Returns
Start index of the inserted entry.

◆ add() [2/2]

template<typename T >
TDeque< T >::size_type sf::TDeque< T >::add ( const TDeque< T > &  tv)

Adds the deques items at the end of the deque.

Returns
Start index of the inserted entries.

◆ addAt()

template<typename T >
bool sf::TDeque< T >::addAt ( const T &  t,
size_type  index 
)

Adds an item at index position.

Parameters
tReference of instance.
indexPosition where to add/insert.
Returns
True on success.

◆ count()

template<typename T >
size_type sf::TDeque< T >::count ( ) const
inline

Returns the amount of entries in the deque.

Returns
Entry count.

◆ detach()

template<typename T >
bool sf::TDeque< T >::detach ( const T &  t)

Removes specific item from the list by instance.

Uses the compare operator from type T to find it.

Parameters
tReference of instance to detach.
Returns
True on success.

◆ detachAt()

template<typename T >
bool sf::TDeque< T >::detachAt ( size_type  index)

Removes specific item from the list by index.

Parameters
indexIndex of the item.
Returns
True on success.

◆ find()

template<typename T >
TDeque< T >::size_type sf::TDeque< T >::find ( const T &  t) const

Finds an entry by instance in the deque.

Returns
Index of the found item and 'npos' when not found.

◆ flush() [1/2]

template<typename T >
void sf::TDeque< T >::flush ( )
inline

Removes all entries from the deque.

◆ flush() [2/2]

template<typename T >
void sf::TDeque< T >::flush ( size_type  stop,
size_type  start = 0 
)
inline

Removes specific range of entries from the deque.

Parameters
stop
start

◆ get() [1/2]

template<typename T >
T & sf::TDeque< T >::get ( size_type  i)
inline

Gets entry from index position.

Parameters
iIndex position
Returns
Instance at position.

◆ get() [2/2]

template<typename T >
const T & sf::TDeque< T >::get ( size_type  i) const
inline

Const version of getting entry from index position.

Parameters
iIndex position
Returns
Instance at position.

◆ getBase() [1/2]

template<typename T >
base_type sf::TDeque< T >::getBase ( )
inline

Returns the base type to access it methods explicitly.

Returns
Base type

◆ getBase() [2/2]

template<typename T >
base_type sf::TDeque< T >::getBase ( ) const
inline

Returns the constant const base type.

Returns
Base type

◆ isEmpty()

template<typename T >
bool sf::TDeque< T >::isEmpty ( ) const
inline

Returns true when empty false otherwise.

Returns
True when empty.

◆ operator[]() [1/2]

template<typename T >
T & sf::TDeque< T >::operator[] ( size_type  i)
inline

Array operator.

Array operator needs reimplementation using std::deque::at() which does a range check in contrast to the std::deque::operator[] functions.

Parameters
iIndex position
Returns
Template type

◆ operator[]() [2/2]

template<typename T >
const T & sf::TDeque< T >::operator[] ( size_type  i) const
inline

Const array operator.

Array operator needs reimplementation using std::deque::at() which does a range check in contrast to the std::deque::operator[] functions.

Parameters
iIndex position
Returns
Template type

◆ write()

template<typename T >
std::ostream & sf::TDeque< T >::write ( std::ostream &  os,
bool  inc_hex 
) const

Writes the content to an output stream.

Parameters
osOutput stream.
inc_hexInclude hex notation when an integer type.
Returns
The passed output stream.

Member Data Documentation

◆ npos

template<typename T >
const size_t sf::TDeque< T >::npos = static_cast<size_type>(-1)
static

Value returned by various member functions when they fail.


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