Vector class template. More...

#include <WVector.h>

Inheritance diagram for Vector< Element >:
Collaboration diagram for Vector< Element >:

Classes

class  Iterator
 

Public Types

using Comparer = int(*)(const Element &lhs, const Element &rhs)
 

Public Member Functions

 Vector (unsigned int initialCapacity=10, unsigned int capacityIncrement=10)
 
 Vector (const Vector &rhv)
 
unsigned int capacity () const
 
template<typename T >
bool contains (const T &elem) const
 
const Element & firstElement () const
 
template<typename T >
int indexOf (const T &elem) const
 
bool isEmpty () const
 
const Element & lastElement () const
 
template<typename T >
int lastIndexOf (const T &elem) const
 
unsigned int count () const override
 
unsigned int size () const
 
void copyInto (Element *array) const
 
bool add (const Element &obj)
 
bool addElement (const Element &obj)
 
bool addElement (Element *objp)
 
void clear ()
 
bool ensureCapacity (unsigned int minCapacity)
 
void removeAllElements ()
 
template<typename T >
bool removeElement (const T &elem)
 
bool setSize (unsigned int newSize)
 Reduce or increase number of items. More...
 
void trimToSize ()
 Reduce capacity to match current size. More...
 
const Element & elementAt (unsigned int index) const
 
bool insertElementAt (const Element &obj, unsigned int index)
 
bool remove (unsigned int index)
 
bool removeElementAt (unsigned int index)
 
bool setElementAt (const Element &obj, unsigned int index)
 
const Element & get (unsigned int index) const
 
const Element & operator[] (unsigned int index) const override
 
Element & operator[] (unsigned int index) override
 
const Vector< Element > & operator= (const Vector< Element > &rhv)
 
const Vector< Element > & operator= (Vector< Element > &&other) noexcept
 
void sort (Comparer compareFunction)
 
Iterator< false > begin ()
 
Iterator< false > end ()
 
const Iterator< true > begin () const
 
const Iterator< true > end () const
 
- Public Member Functions inherited from Countable< Element >
virtual ~Countable ()
 
const Element & at (unsigned int i) const
 

Protected Types

using ElementList = wiring_private::List< Element >
 

Protected Member Functions

void copyFrom (const Vector &rhv)
 

Protected Attributes

unsigned int _size {0}
 
unsigned int _increment {0}
 
ElementList _data
 

Detailed Description

template<typename Element>
class Vector< Element >

Vector class template.

Member Typedef Documentation

◆ Comparer

template<typename Element >
using Vector< Element >::Comparer = int (*)(const Element& lhs, const Element& rhs)

◆ ElementList

template<typename Element >
using Vector< Element >::ElementList = wiring_private::List<Element>
protected

Constructor & Destructor Documentation

◆ Vector() [1/2]

template<typename Element >
Vector< Element >::Vector ( unsigned int  initialCapacity = 10,
unsigned int  capacityIncrement = 10 
)
inline

◆ Vector() [2/2]

template<typename Element >
Vector< Element >::Vector ( const Vector< Element > &  rhv)
inline

Member Function Documentation

◆ add()

template<typename Element >
bool Vector< Element >::add ( const Element &  obj)
inline

◆ addElement() [1/2]

template<class Element >
bool Vector< Element >::addElement ( const Element &  obj)

◆ addElement() [2/2]

template<class Element >
bool Vector< Element >::addElement ( Element *  objp)

◆ begin() [1/2]

template<typename Element >
Iterator<false> Vector< Element >::begin ( )
inline

◆ begin() [2/2]

template<typename Element >
const Iterator<true> Vector< Element >::begin ( ) const
inline

◆ capacity()

template<typename Element >
unsigned int Vector< Element >::capacity ( ) const
inline

◆ clear()

template<typename Element >
void Vector< Element >::clear ( void  )
inline

◆ contains()

template<typename Element >
template<typename T >
bool Vector< Element >::contains ( const T &  elem) const
inline

◆ copyFrom()

template<class Element >
void Vector< Element >::copyFrom ( const Vector< Element > &  rhv)
protected

◆ copyInto()

template<class Element >
void Vector< Element >::copyInto ( Element *  array) const

◆ count()

template<typename Element >
unsigned int Vector< Element >::count ( ) const
inlineoverridevirtual

Implements Countable< Element >.

◆ elementAt()

template<typename Element >
const Element& Vector< Element >::elementAt ( unsigned int  index) const
inline

◆ end() [1/2]

template<typename Element >
Iterator<false> Vector< Element >::end ( )
inline

◆ end() [2/2]

template<typename Element >
const Iterator<true> Vector< Element >::end ( ) const
inline

◆ ensureCapacity()

template<class Element >
bool Vector< Element >::ensureCapacity ( unsigned int  minCapacity)

◆ firstElement()

template<typename Element >
const Element& Vector< Element >::firstElement ( ) const
inline

◆ get()

template<typename Element >
const Element& Vector< Element >::get ( unsigned int  index) const
inline

◆ indexOf()

template<class Element >
template<typename T >
int Vector< Element >::indexOf ( const T &  elem) const

◆ insertElementAt()

template<class Element >
bool Vector< Element >::insertElementAt ( const Element &  obj,
unsigned int  index 
)

◆ isEmpty()

template<typename Element >
bool Vector< Element >::isEmpty ( ) const
inline

◆ lastElement()

template<typename Element >
const Element& Vector< Element >::lastElement ( ) const
inline

◆ lastIndexOf()

template<class Element >
template<typename T >
int Vector< Element >::lastIndexOf ( const T &  elem) const

◆ operator=() [1/2]

template<typename Element >
const Vector<Element>& Vector< Element >::operator= ( const Vector< Element > &  rhv)
inline

◆ operator=() [2/2]

template<typename Element >
const Vector<Element>& Vector< Element >::operator= ( Vector< Element > &&  other)
inlinenoexcept

◆ operator[]() [1/2]

template<typename Element >
const Element& Vector< Element >::operator[] ( unsigned int  index) const
inlineoverridevirtual

Implements Countable< Element >.

◆ operator[]() [2/2]

template<typename Element >
Element& Vector< Element >::operator[] ( unsigned int  index)
inlineoverridevirtual

Implements Countable< Element >.

◆ remove()

template<typename Element >
bool Vector< Element >::remove ( unsigned int  index)
inline

◆ removeAllElements()

template<typename Element >
void Vector< Element >::removeAllElements ( )
inline

◆ removeElement()

template<typename Element >
template<typename T >
bool Vector< Element >::removeElement ( const T &  elem)
inline

◆ removeElementAt()

template<class Element >
bool Vector< Element >::removeElementAt ( unsigned int  index)

◆ setElementAt()

template<class Element >
bool Vector< Element >::setElementAt ( const Element &  obj,
unsigned int  index 
)

◆ setSize()

template<class Element >
bool Vector< Element >::setSize ( unsigned int  newSize)

Reduce or increase number of items.

Return values
trueon success, false on memory reallocation failure

If increasing number of items, new items will be set to current nil value. If reducing number of items, old items will be deleted.

◆ size()

template<typename Element >
unsigned int Vector< Element >::size ( ) const
inline

◆ sort()

template<class Element >
void Vector< Element >::sort ( Comparer  compareFunction)

◆ trimToSize()

template<typename Element >
void Vector< Element >::trimToSize ( )
inline

Reduce capacity to match current size.

Member Data Documentation

◆ _data

template<typename Element >
ElementList Vector< Element >::_data
protected

◆ _increment

template<typename Element >
unsigned int Vector< Element >::_increment {0}
protected

◆ _size

template<typename Element >
unsigned int Vector< Element >::_size {0}
protected

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