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

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

#include <TVector.h>

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

Public Types

typedef std::vector< 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 vector template.
 
typedef TIterator< value_typeiter_type
 Iteration type of the template.
 
typedef const iter_type const_iter_type
 Iteration const type of the template.
 

Public Member Functions

 TVector ()=default
 Default constructor.
 
 TVector (const TVector &v)
 Copy constructor.
 
 TVector (TVector &&) noexcept=default
 Move constructor.
 
TVectoroperator= (const TVector &v) noexcept
 Assignment operator.
 
TVectoroperator= (TVector &&v) noexcept
 Assignment move operator.
 
template<typename InputIterator >
 TVector (InputIterator first, InputIterator last)
 Initializing constructor using an iterator.
 
 TVector (std::initializer_list< value_type > list)
 Initializing constructor using list like:
TVector vect{1,2,3,4,5,6,7}
 
 TVector (const base_type &sv)
 Copy constructor for base type.
 
 TVector (size_type sz)
 Initializing constructor.
 
size_type add (const T &t)
 Adds item at the end of the vector.
 
size_type add (T &&t)
 Adds item at the end of the vector.
 
TVector< T > & append (const T &t)
 Appends an entry to the vectors items at the end of the vector but returns itself.
 
TVector< T > & append (T &&t)
 Appends an entry to the vectors items at the end of the vector but returns itself.
 
size_type add (const TVector< T > &)
 Adds the vectors items at the end of the vector.
 
bool addAt (const T &t, size_type index)
 Adds an item at index position.
 
bool addAt (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 vector.
 
void flush (size_type stop, size_type start=0)
 Removes specific range of entries from the vector.
 
size_type find (const T &) const
 Finds an entry by instance in the vector.
 
size_type count () const
 Returns the amount of entries in the vector.
 
T & first ()
 Gets the first element of the vector.
 
const T & first () const noexcept
 Gets the first element of the vector.
 
T & last ()
 Gets the last element of the vector.
 
const T & last () const noexcept
 Gets the last element of the vector.
 
bool startsWith (T t) const
 Checks if the first element is of the passed value.
 
bool endsWith (T t) const
 Checks if the last element is of the passed value.
 
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::TVector< T >

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

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

Template Parameters
TType contained by the vector.

Member Typedef Documentation

◆ base_type

template<typename T >
typedef std::vector<T> sf::TVector< T >::base_type

Base type of this template .

◆ const_iter_type

template<typename T >
typedef const iter_type sf::TVector< T >::const_iter_type

Iteration const type of the template.

◆ iter_type

template<typename T >
typedef TIterator<value_type> sf::TVector< T >::iter_type

Iteration type of the template.

◆ size_type

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

Size type of this template.

◆ value_type

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

Value type contained by this vector template.

Constructor & Destructor Documentation

◆ TVector() [1/7]

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

Default constructor.

◆ TVector() [2/7]

template<typename T >
sf::TVector< T >::TVector ( const TVector< T > &  v)
inline

Copy constructor.

◆ TVector() [3/7]

template<typename T >
sf::TVector< T >::TVector ( TVector< T > &&  )
defaultnoexcept

Move constructor.

◆ TVector() [4/7]

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

Initializing constructor using an iterator.

◆ TVector() [5/7]

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

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

◆ TVector() [6/7]

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

Copy constructor for base type.

◆ TVector() [7/7]

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

Initializing constructor.

Parameters
szSize of the vector.

Member Function Documentation

◆ add() [1/3]

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

Adds item at the end of the vector.

Returns
Start index of the inserted entry.

◆ add() [2/3]

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

Adds the vectors items at the end of the vector.

Returns
Start index of the inserted entries.

◆ add() [3/3]

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

Adds item at the end of the vector.

Returns
Start index of the inserted entry.

◆ addAt() [1/2]

template<typename T >
bool sf::TVector< 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.

◆ addAt() [2/2]

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

Adds an item at index position.

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

◆ append() [1/2]

template<typename T >
TVector< T > & sf::TVector< T >::append ( const T &  t)

Appends an entry to the vectors items at the end of the vector but returns itself.

Returns
Start index of the inserted entries.

◆ append() [2/2]

template<typename T >
TVector< T > & sf::TVector< T >::append ( T &&  t)

Appends an entry to the vectors items at the end of the vector but returns itself.

Returns
Start index of the inserted entries.

◆ count()

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

Returns the amount of entries in the vector.

Returns
Entry count.

◆ detach()

template<typename T >
bool sf::TVector< 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::TVector< T >::detachAt ( size_type  index)

Removes specific item from the list by index.

Parameters
indexIndex of the item.
Returns
True on success.

◆ endsWith()

template<typename T >
bool sf::TVector< T >::endsWith ( t) const
inline

Checks if the last element is of the passed value.

◆ find()

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

Finds an entry by instance in the vector.

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

◆ first() [1/2]

template<typename T >
T & sf::TVector< T >::first ( )
inline

Gets the first element of the vector.

Returns
Reference of the typed value.

◆ first() [2/2]

template<typename T >
const T & sf::TVector< T >::first ( ) const
inlinenoexcept

Gets the first element of the vector.

Returns
Const reference of the typed value.

◆ flush() [1/2]

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

Removes all entries from the vector.

◆ flush() [2/2]

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

Removes specific range of entries from the vector.

Parameters
stop
start

◆ get() [1/2]

template<typename T >
T & sf::TVector< 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::TVector< 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::TVector< T >::getBase ( )
inline

Returns the base type to access it methods explicitly.

Returns
Base type

◆ getBase() [2/2]

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

Returns the constant const base type.

Returns
Base type

◆ isEmpty()

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

Returns true when empty false otherwise.

Returns
True when empty.

◆ last() [1/2]

template<typename T >
T & sf::TVector< T >::last ( )
inline

Gets the last element of the vector.

Returns
Const reference of the typed value.

◆ last() [2/2]

template<typename T >
const T & sf::TVector< T >::last ( ) const
inlinenoexcept

Gets the last element of the vector.

Returns
Const reference of the typed value.

◆ operator=() [1/2]

template<typename T >
TVector & sf::TVector< T >::operator= ( const TVector< T > &  v)
inlinenoexcept

Assignment operator.

◆ operator=() [2/2]

template<typename T >
TVector & sf::TVector< T >::operator= ( TVector< T > &&  v)
inlinenoexcept

Assignment move operator.

◆ operator[]() [1/2]

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

Array operator.

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

Parameters
iIndex position
Returns
Template type

◆ operator[]() [2/2]

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

Const array operator.

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

Parameters
iIndex position
Returns
Template type

◆ startsWith()

template<typename T >
bool sf::TVector< T >::startsWith ( t) const
inline

Checks if the first element is of the passed value.

◆ write()

template<typename T >
std::ostream & sf::TVector< 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::TVector< 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: