Vector class template. More...

#include <WVector.h>

Inheritance diagram for Vector< Element >:
[legend]
Collaboration diagram for Vector< Element >:
[legend]

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)
 
 ~Vector ()
 
unsigned int capacity () const
 
bool contains (const Element &elem) const
 
const Element & firstElement () const
 
int indexOf (const Element &elem) const
 
bool isEmpty () const
 
const Element & lastElement () const
 
int lastIndexOf (const Element &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 ()
 
bool removeElement (const Element &obj)
 
bool setSize (unsigned int newSize)
 
void trimToSize ()
 
const Element & elementAt (unsigned int index) const
 
bool insertElementAt (const Element &obj, unsigned int index)
 
const void remove (unsigned int index)
 
void 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= (const Vector< Element > &&other) noexcept
 
void sort (Comparer compareFunction)
 
Iterator< false > begin ()
 
Iterator< false > end ()
 
Iterator< true > begin () const
 
Iterator< true > end () const
 
- Public Member Functions inherited from Countable< Element >
virtual ~Countable ()
 
const Element & at (unsigned int i) const
 

Protected Member Functions

void copyFrom (const Vector &rhv)
 

Protected Attributes

unsigned int _size = 0
 
unsigned int _capacity = 0
 
unsigned int _increment
 
Element ** _data = nullptr
 

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)

Constructor & Destructor Documentation

◆ Vector() [1/2]

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

◆ Vector() [2/2]

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

◆ ~Vector()

template<class Element >
Vector< Element >::~Vector ( )

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>
Iterator<true> Vector< Element >::begin ( ) const
inline

◆ capacity()

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

◆ clear()

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

◆ contains()

template<class Element>
bool Vector< Element >::contains ( const Element &  elem) const

◆ 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<class Element >
const Element & Vector< Element >::elementAt ( unsigned int  index) const

◆ end() [1/2]

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

◆ end() [2/2]

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

◆ ensureCapacity()

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

◆ firstElement()

template<class Element >
const Element & Vector< Element >::firstElement ( ) const

◆ get()

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

◆ indexOf()

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

◆ insertElementAt()

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

◆ isEmpty()

template<class Element >
bool Vector< Element >::isEmpty ( ) const

◆ lastElement()

template<class Element >
const Element & Vector< Element >::lastElement ( ) const

◆ lastIndexOf()

template<class Element>
int Vector< Element >::lastIndexOf ( const Element &  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= ( const Vector< Element > &&  other)
inlinenoexcept

◆ operator[]() [1/2]

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

Implements Countable< Element >.

◆ operator[]() [2/2]

template<class Element >
Element & Vector< Element >::operator[] ( unsigned int  index)
overridevirtual

Implements Countable< Element >.

◆ remove()

template<class Element >
const void Vector< Element >::remove ( unsigned int  index)

◆ removeAllElements()

template<class Element >
void Vector< Element >::removeAllElements ( )

◆ removeElement()

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

◆ removeElementAt()

template<class Element >
void 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)

◆ size()

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

◆ sort()

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

◆ trimToSize()

template<class Element >
void Vector< Element >::trimToSize ( )

Member Data Documentation

◆ _capacity

template<typename Element>
unsigned int Vector< Element >::_capacity = 0
protected

◆ _data

template<typename Element>
Element** Vector< Element >::_data = nullptr
protected

◆ _increment

template<typename Element>
unsigned int Vector< Element >::_increment
protected

◆ _size

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

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