- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# fm::vector< T, PRIMITIVE > Class Template Reference
[Mathematics Classes.]

A dynamically-sized array. More...

`#include <FMArray.h>`

List of all members.

## Public Types
typedef T * | iterator
| The basic list iterator.
typedef const T * | const_iterator
| The non-modifiable list iterator.
## Public Member Functions
| vector ()
| Default constructor.
| vector (size_t size)
| Constructor.
| vector (size_t size, const T &defaultValue)
| Constructor.
| vector (const fm::vector< T, PRIMITIVE > &copy)
| Copy constructor.
| vector (const T *values, size_t count)
| Constructor.
| ~vector ()
| Destructor.
T ** | GetDataPtr ()
| Retrieves a pointer to our internal buffer.
const T ** | GetDataPtr () const
| See above.
template<class Type2>
iterator | find (const Type2 &value)
| Retrieves an iterator for a given element.
template<class Type2>
const_iterator | find (const Type2 &value) const
| See above.
void | sort ()
| Sorts this vector using the default comparisons operator.
void | sort (comparator< T > &comp)
| Sorts this vector using the given fm::comparator.
iterator | erase (iterator it)
| Removes the value at the given position within the list.
void | erase (iterator first, iterator last)
| Removes a range of values from the list.
void | erase (size_t first, size_t last)
| Removes a range of values from the list.
bool | erase (const T &value)
| Removes a value contained within the list, once.
void | erase (size_t index)
| Removes an indexed value contained within the list.
bool | contains (const T &value) const
| Retrieves whether the list contains a given value.
template<class V2, class V3>
void | replace (const V2 &oldValue, const V3 &newValue)
| Replaces all cases of one value into another value.
template<class V2, class V3>
void | replace (iterator start, iterator end, const V2 &oldValue, const V3 &newValue)
| Replaces the instances of one value into another value within a given segment of the list.
size_t | size () const
| Retrieves the number of values contained in the list.
bool | empty () const
| Retrieves whether there are any elements in the list.
void | resize (size_t count)
| Sets the number of values contained in the list.
void | resize (size_t count, const T &value)
| Sets the number of values contained in the list.
void | clear ()
| Removes all the element in the list.
void | reserve (size_t count)
| Pre-allocate the list to a certain number of values.
size_t | capacity ()
| Retrieves the maximum size the array can grow to without allocating memory size is always less than or equal to capacity.
size_t | capacity () const
| See above.
iterator | begin ()
| Retrieves the iterator for the first value in the list.
const_iterator | begin () const
| See above.
iterator | end ()
| Retrieves the iterator just past the last value in the list.
const_iterator | end () const
| See above.
iterator | insert (iterator it, const T &item)
| Inserts a new item at a given position within the list.
void | insert (size_t index, const T &item)
| Inserts a new item at a given position within the list.
void | push_back (const T &item)
| Inserts a new item at the end of the list.
void | push_front (const T &item)
| Inserts a new item at the front of the list.
void | pop_back ()
| Removes the last item from a list.
void | pop_front ()
| Removes the first item from a list.
template<typename _IT>
void | insert (iterator it, _IT first, _IT last)
| Inserts multiple items at a given position within the list.
void | insert (iterator it, size_t count, const T &item, bool noInit=false)
| Inserts one item, multiple times at a given position within the list.
void | insert (size_t index, size_t count, const T &value)
| Inserts one value, multiple times, to this list.
void | insert (iterator it, const T *first, size_t count)
| Inserts multiple items at a given position within the list, from a static list.
void | insert (size_t index, const T *values, size_t count)
| Inserts multiple values to this list.
T & | front ()
| Retrieves the first element of the pointer array.
const T & | front () const
| See above.
T & | back ()
| Retrieves the last element of the pointer array.
const T & | back () const
| See above.
T & | at (size_t index)
| Retrieves an indexed object in the pointer array.
const T & | at (size_t index) const
| See above.
template<class INTEGER>
T & | operator[] (INTEGER index)
| See above.
template<class INTEGER>
const T & | operator[] (INTEGER index) const
| See above.
bool | operator== (const fm::vector< T, PRIMITIVE > &other) const
| Retrieves whether two lists are equivalent.
vector< T, PRIMITIVE > & | operator= (const fm::vector< T, PRIMITIVE > &rhs)
| Copy operator.
## Protected Attributes
size_t | reserved
| The capacity of the vector.
size_t | sized
| The number of values contained in the vector.
T * | heapBuffer
| The heap buffer that contains the values.

## Detailed Description

### template<class T, bool PRIMITIVE = false>
class fm::vector< T, PRIMITIVE >

A dynamically-sized array.

Intentionally has an interface similar to the standard C++ vector class. It's implement should be very similar yet more lightweight.

We have also added useful extra functionality, such as a constructor that takes in a constant-sized array, comparison with a constant-sized array, erase and find functions that take in a value, etc.

## Constructor & Destructor Documentation

template<class T, bool PRIMITIVE = false>
fm::vector< T, PRIMITIVE >::vector | ( | size_t | size | ) | `[inline]`

  | Constructor. Builds a dynamically-sized array of the wanted size. Parameters:
  | size | The wanted size of the array.

template<class T, bool PRIMITIVE = false>
fm::vector< T, PRIMITIVE >::vector | ( | size_t | size,
|  | const T & | defaultValue
| ) | `[inline]`

  | Constructor. Builds a dynamically-sized array of the wanted size. Parameters:
  | size | The wanted size of the array
  | defaultValue | The default value to use for all the entries of the array.

template<class T, bool PRIMITIVE = false>
fm::vector< T, PRIMITIVE >::vector | ( | const fm::vector< T, PRIMITIVE > & | copy | ) | `[inline]`

  | Copy constructor. Parameters:
  | copy | The dynamically-sized array to copy the values from.

template<class T, bool PRIMITIVE = false>
fm::vector< T, PRIMITIVE >::vector | ( | const T * | values,
|  | size_t | count
| ) | `[inline]`

  | Constructor. Builds a dynamically-sized array from a constant-sized array. Parameters:
  | values | A constant-sized array of floating-point values.
  | count | The size of the constant-sized array.

## Member Function Documentation

template<class T, bool PRIMITIVE = false>
T& fm::vector< T, PRIMITIVE >::at | ( | size_t | index | ) | `[inline]`

  | Retrieves an indexed object in the pointer array. Parameters:
  | index | An index.
Returns: The given object. Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
T& fm::vector< T, PRIMITIVE >::back | ( |  | ) | `[inline]`

| Retrieves the last element of the pointer array. Returns: The last element in the pointer array. Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, fm::stringT< CH >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
iterator fm::vector< T, PRIMITIVE >::begin | ( |  | ) | `[inline]`

| Retrieves the iterator for the first value in the list. Returns: The iterator for the first value in the list. Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
size_t fm::vector< T, PRIMITIVE >::capacity | ( |  | ) | `[inline]`

| Retrieves the maximum size the array can grow to without allocating memory size is always less than or equal to capacity. Returns: The number of values the array currently has memory allocated for

template<class T, bool PRIMITIVE = false>
bool fm::vector< T, PRIMITIVE >::contains | ( | const T & | value | ) | const`[inline]`

  | Retrieves whether the list contains a given value. Parameters:
  | value | A value that could be contained in the list.
Returns: Whether the list contains this value.

template<class T, bool PRIMITIVE = false>
iterator fm::vector< T, PRIMITIVE >::end | ( |  | ) | `[inline]`

| Retrieves the iterator just past the last value in the list. Returns: The iterator for just past the last value in the list. Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::erase | ( | size_t | index | ) | `[inline]`

  | Removes an indexed value contained within the list. Parameters:
  | index | The index of the value to erase.
Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
bool fm::vector< T, PRIMITIVE >::erase | ( | const T & | value | ) | `[inline]`

  | Removes a value contained within the list, once. Parameters:
  | value | The value, contained within the list, to erase from it.
Returns: Whether the value was found and erased from the list.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::erase | ( | size_t | first,
|  | size_t | last
| ) | `[inline]`

  | Removes a range of values from the list. Parameters:
  | first | The index of the first value to remove.
  | last | The index just passed the last value to remove.
Reimplemented in FUObjectContainer< ObjectClass >, fm::stringT< CH >, FUTrackedList< ObjectClass >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::erase | ( | iterator | first,
|  | iterator | last
| ) | `[inline]`

  | Removes a range of values from the list. The range is determined as every value between and including the first value, up to the last value, but not including the last value. Parameters:
  | first | An iterator pointing to the first list value to remove.
  | last | An iterator past the last list value to remove.

template<class T, bool PRIMITIVE = false>
iterator fm::vector< T, PRIMITIVE >::erase | ( | iterator | it | ) | `[inline]`

  | Removes the value at the given position within the list. Parameters:
  | it | The list position for the value to remove.

template<class T, bool PRIMITIVE = false>
template<class Type2>
iterator fm::vector< T, PRIMITIVE >::find | ( | const Type2 & | value | ) | `[inline]`

  | Retrieves an iterator for a given element. Parameters:
  | value | The value, contained within the list, to search for.
Returns: An iterator to this element. The end() iterator is returned if the value is not found.

template<class T, bool PRIMITIVE = false>
T& fm::vector< T, PRIMITIVE >::front | ( |  | ) | `[inline]`

| Retrieves the first element of the pointer array. Returns: The first element in the pointer array. Reimplemented in fm::pvector< T >, FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, fm::pvector< FCDEntityReference >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
T** fm::vector< T, PRIMITIVE >::GetDataPtr | ( |  | ) | `[inline]`

| Retrieves a pointer to our internal buffer. Be very careful when using this. Returns: A pointer to our internal buffer.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::insert | ( | size_t | index,
|  | const T * | values,
|  | size_t | count
| ) | `[inline]`

  | Inserts multiple values to this list. Parameters:
  | index | Where to insert the values.
  | values | A static list of values.
  | count | The number of values to insert.
Reimplemented in fm::stringT< CH >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::insert | ( | iterator | it,
|  | const T * | first,
|  | size_t | count
| ) | `[inline]`

  | Inserts multiple items at a given position within the list, from a static list. Parameters:
  | it | An iterator pointing to where to insert the items.
  | first | A pointer to the first item to insert.
  | count | The number of element within the static list that must be inserted within the list.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::insert | ( | size_t | index,
|  | size_t | count,
|  | const T & | value
| ) | `[inline]`

  | Inserts one value, multiple times, to this list. Parameters:
  | index | Where to insert the value.
  | count | The number of times to insert this value.
  | value | The value to insert.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::insert | ( | iterator | it,
|  | size_t | count,
|  | const T & | item,
|  | bool | noInit = `false`
| ) | `[inline]`

  | Inserts one item, multiple times at a given position within the list. Parameters:
  | it | An iterator pointing to where to insert the item.
  | count | The number of times to insert the item.
  | item | The item to insert.

template<class T, bool PRIMITIVE = false>
template<typename _IT>
void fm::vector< T, PRIMITIVE >::insert | ( | iterator | it,
|  | _IT | first,
|  | _IT | last
| ) | `[inline]`

  | Inserts multiple items at a given position within the list. Parameters:
  | it | An iterator pointing to where to insert the items.
  | first | An iterator pointing to the first item to insert.
  | last | An iterator past the last item to insert.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::insert | ( | size_t | index,
|  | const T & | item
| ) | `[inline]`

  | Inserts a new item at a given position within the list. Parameters:
  | index | Where to insert the given value.
  | item | The item to insert.

template<class T, bool PRIMITIVE = false>
iterator fm::vector< T, PRIMITIVE >::insert | ( | iterator | it,
|  | const T & | item
| ) | `[inline]`

  | Inserts a new item at a given position within the list. Parameters:
  | it | An iterator pointing to where to insert the item.
  | item | The item to insert.
Returns: An iterator pointing to the inserted item within the list.

template<class T, bool PRIMITIVE = false>
vector<T,PRIMITIVE>& fm::vector< T, PRIMITIVE >::operator= | ( | const fm::vector< T, PRIMITIVE > & | rhs | ) | `[inline]`

  | Copy operator. Copies the contents of one vector to another. Parameters:
  | rhs | The vector to copy (RHS of operation).
Returns: A reference to this (LHS of operation).

template<class T, bool PRIMITIVE = false>
bool fm::vector< T, PRIMITIVE >::operator== | ( | const fm::vector< T, PRIMITIVE > & | other | ) | const`[inline]`

  | Retrieves whether two lists are equivalent. Parameters:
  | other | A second list.
Returns: Whether the two lists are equivalent.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::pop_front | ( |  | ) | `[inline]`

| Removes the first item from a list. This operation is very expansive and not recommended for real-time operations. Reimplemented in FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::push_back | ( | const T & | item | ) | `[inline]`

  | Inserts a new item at the end of the list. Parameters:
  | item | The item to insert.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::push_front | ( | const T & | item | ) | `[inline]`

  | Inserts a new item at the front of the list. This operation is very expansive and not recommended for real-time operations. Parameters:
  | item | The item to insert.

template<class T, bool PRIMITIVE = false>
template<class V2, class V3>
void fm::vector< T, PRIMITIVE >::replace | ( | iterator | start,
|  | iterator | end,
|  | const V2 & | oldValue,
|  | const V3 & | newValue
| ) | `[inline]`

  | Replaces the instances of one value into another value within a given segment of the list. Parameters:
  | start | The iterator at which to start replacing values.
  | end | The iterator at which to end replacing values.
  | oldValue | The value to replace.
  | newValue | The value which replaces the old value.

template<class T, bool PRIMITIVE = false>
template<class V2, class V3>
void fm::vector< T, PRIMITIVE >::replace | ( | const V2 & | oldValue,
|  | const V3 & | newValue
| ) | `[inline]`

  | Replaces all cases of one value into another value. Parameters:
  | start | The iterator at which to start replacing values.
  | end | The iterator at which to end replacing values.
  | oldValue | The value to replace.
  | newValue | The value which replaces the old value.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::reserve | ( | size_t | count | ) | `[inline]`

  | Pre-allocate the list to a certain number of values. You can use reserve zero values in order to clear the memory used by this list. This function is useful when optimizing. Parameters:
  | count | The new number of values pre-allocated in the list.
Reimplemented in FUObjectContainer< ObjectClass >, FUTrackedList< ObjectClass >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::resize | ( | size_t | count,
|  | const T & | value
| ) | `[inline]`

  | Sets the number of values contained in the list. Parameters:
  | count | The new number of values contained in the list.
  | value | The value to assign to the new entries in the list.
Reimplemented in fm::stringT< CH >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::resize | ( | size_t | count | ) | `[inline]`

  | Sets the number of values contained in the list. Parameters:
  | count | The new number of values contained in the list.
Reimplemented in fm::pvector< T >, fm::stringT< CH >, fm::pvector< FUPlugin >, fm::pvector< ObjectClass >, fm::pvector< FCDAnimated >, fm::pvector< _NODE >, fm::pvector< FCDPlaceHolder >, and fm::pvector< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
size_t fm::vector< T, PRIMITIVE >::size | ( |  | ) | const`[inline]`

| Retrieves the number of values contained in the list. Returns: The number of values contained in the list. Reimplemented in FUObjectContainer< ObjectClass >, fm::stringT< CH >, FUTrackedList< ObjectClass >, FUObjectContainer< FUPlugin >, FUObjectContainer< FCDAnimated >, FUObjectContainer< FCDPlaceHolder >, and FUTrackedList< FCDEntityReference >.

template<class T, bool PRIMITIVE = false>
void fm::vector< T, PRIMITIVE >::sort | ( | comparator< T > & | comp | ) | `[inline]`

  | Sorts this vector using the given fm::comparator. Parameters:
  | comparator | The comparator used to sort the vector.

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

- FMath/FMArray.h