This Array template implements a vector collection class.
More...
#include <List.h>
|
T * | addFirst (T *t) |
| Add an element at the array's beginning.
|
|
T * | addLast (T *t) |
| Add an element at the array's end.
|
|
T * | add (T *t) |
| Add an element at the list's end.
|
|
T * | insertBefore (T *item, T *elem) |
| Insert an element before a given element.
|
|
T * | insertAfter (T *item, T *elem) |
| Insert an element after a given element.
|
|
T * | removeFirst () |
| Remove the first element.
|
|
T * | removeLast () |
| Remove the last element.
|
|
void | clearAll () |
| Remove and delete all elements from the receiver.
|
|
void | clear () |
| Empty the receiver list without freeing the memory of the list elements.
|
|
void | clear (int i) |
| Clear a specified element, thus the element pointer is set to 0.
|
|
T * | remove (T *item) |
| Remove an element.
|
|
T * | remove (unsigned int i) |
| Remove an element using a cursor.
|
|
T * | getNth (int n) const |
| Return the nth element of the list.
|
|
int | index (T *t) const |
| Return the index of a given element.
|
|
T * | first () const |
| Return the first element.
|
|
T * | last () const |
| Return the last element.
|
|
T * | overwriteNth (int n, T *t) |
| Replace the nth element with a given one.
|
|
T & | operator[] (int n) const |
|
int | trim (int n) |
| Remove the n elements from the end of the receiver.
|
|
int | size () const |
| Get the element count of the list.
|
|
int | empty () const |
| Check whether the list is empty.
|
|
Array< T > * | clone () |
| Clone the array.
|
|
Array< T > & | operator= (const Array< T > &o) |
|
| Array () |
| Default constructor.
|
|
| ~Array () |
| Destructor (deletes all elements of the list)
|
|
template<class T>
class Array< T >
This Array template implements a vector collection class.
- Version
- 4.0.0
- Author
- Frank Fock
Destructor (deletes all elements of the list)
template<class T>
T* Array< T >::add |
( |
T * |
t | ) |
|
|
inline |
Add an element at the list's end.
- Parameters
-
t | a pointer to an instance to be added. |
- Returns
- the same pointer t
template<class T>
T* Array< T >::addFirst |
( |
T * |
t | ) |
|
|
inline |
Add an element at the array's beginning.
- Parameters
-
t | a pointer to an instance to be added. |
- Returns
- the same pointer t
template<class T>
T* Array< T >::addLast |
( |
T * |
t | ) |
|
|
inline |
Add an element at the array's end.
- Parameters
-
t | a pointer to an instance to be added. |
- Returns
- the same pointer t
template<class T>
void Array< T >::clear |
( |
| ) |
|
|
inline |
Empty the receiver list without freeing the memory of the list elements.
template<class T>
void Array< T >::clear |
( |
int |
i | ) |
|
|
inline |
Clear a specified element, thus the element pointer is set to 0.
- Parameters
-
i | the index of the element to clear. |
template<class T>
void Array< T >::clearAll |
( |
| ) |
|
|
inline |
Remove and delete all elements from the receiver.
template<class T>
int Array< T >::empty |
( |
| ) |
const |
|
inline |
Check whether the list is empty.
- Returns
- a value != 0, if the list is empty. A value of 0, if the list is not empty.
template<class T>
T* Array< T >::first |
( |
| ) |
const |
|
inline |
Return the first element.
- Returns
- the pointer to the first element, or 0 if the receiver is empty.
template<class T>
T* Array< T >::getNth |
( |
int |
n | ) |
const |
|
inline |
Return the nth element of the list.
- Parameters
-
n | points to the elements (starting from 0) to return. |
- Returns
- a pointer to a list item, or 0 if the list does contain less than n elements.
template<class T>
int Array< T >::index |
( |
T * |
t | ) |
const |
|
inline |
Return the index of a given element.
- Parameters
-
element | a pointer to a list element. |
- Returns
- the index (counted from 0) of element within the receiver. If the receiver does not contain element, then -1 is returned.
template<class T>
T* Array< T >::insertAfter |
( |
T * |
item, |
|
|
T * |
elem |
|
) |
| |
|
inline |
Insert an element after a given element.
- Parameters
-
newElement | the element to add. |
element | a pointer to an element of the list. If the receiver does not contain such an element, then item is appended to the list. |
template<class T>
T* Array< T >::insertBefore |
( |
T * |
item, |
|
|
T * |
elem |
|
) |
| |
|
inline |
Insert an element before a given element.
- Parameters
-
newElement | the element to add. |
element | a pointer to an element of the list. If the receiver does not contain such an element, then item is appended to the list. |
template<class T>
T* Array< T >::last |
( |
| ) |
const |
|
inline |
Return the last element.
- Returns
- the pointer to the last element, or 0 if the receiver is empty.
template<class T>
T& Array< T >::operator[] |
( |
int |
n | ) |
const |
|
inline |
template<class T>
T* Array< T >::overwriteNth |
( |
int |
n, |
|
|
T * |
t |
|
) |
| |
|
inline |
Replace the nth element with a given one.
- Parameters
-
n | the index of the element to replace (counted from 0). |
element | a pointer to an element. |
- Returns
- the pointer to the new element at index n, or 0 if the receiver contains less than n elements.
template<class T>
T* Array< T >::remove |
( |
T * |
item | ) |
|
|
inline |
Remove an element.
- Parameters
-
item | a pointer to a list item. |
- Returns
- the pointer to the given item, or 0 if the receiver does not contain item.
template<class T>
T* Array< T >::remove |
( |
unsigned int |
i | ) |
|
|
inline |
Remove an element using a cursor.
Note: The cursor is invalid after this operation!
- Parameters
-
item | a pointer to a list cursor. |
- Returns
- the pointer to the removed item.
template<class T>
T* Array< T >::removeFirst |
( |
| ) |
|
|
inline |
Remove the first element.
- Returns
- a pointer to the removed element or 0 if the list is empty.
template<class T>
T* Array< T >::removeLast |
( |
| ) |
|
|
inline |
Remove the last element.
- Returns
- a pointer to the removed item or 0 if the list is empty.
template<class T>
int Array< T >::size |
( |
| ) |
const |
|
inline |
Get the element count of the list.
- Returns
- the receiver's size.
template<class T>
int Array< T >::trim |
( |
int |
n | ) |
|
|
inline |
Remove the n elements from the end of the receiver.
- Parameters
-
n | the number of elements to be removed. |
- Returns
- the count of successfully removed elements.
template<class T>
unsigned int Array< T >::sz |
|
protected |
The documentation for this class was generated from the following file: