Public Member Functions

kNet::Array< T, AllocT > Class Template Reference

std::vector -equivalent. More...

#include <Array.h>

List of all members.

Public Member Functions

size_t size () const
size_t capacity () const
void set_allocator (AllocT *allocator_)
 Sets the allocator used by this Array.
AllocT * get_allocator () const
const T * beginptr () const
 Pointer to the first element.
const T * endptr () const
 Pointer to one past the last used element.
const T * capptr () const
 Pointer to the first element beyond allocated memory.
iterator begin ()
iterator end ()
const T * end () const
void insert (int i, const T &val)
 Inserts an element before the ith element of the Array. Running time is O(n).
bool MembersUnique () const
 Returns true if the members of this array all have distinct values. Tests each pair and runs in O(n^2).
void push_front (const T &val)
 Inserts an element to the front of the Array. Running time is O(n).
void push_back (const T &val)
 Inserts the given element to back of the Array. Running time is O(1).
void push_back_unsafe (const T &val)
 Inserts the given element to back of the Array, but without doing bounds checking.
T & push_back_unsafe_pod ()
 Inserts an uninitialized value to the back of the Array, and returns a reference to it.
T & push_back ()
 Inserts a default-constructed element to back of the Array. Running time is O(1).
void erase (int start, int end)
 Erases a range of elements, excluding the element at index end.
void erase (int i)
 Removes the ith element from the array. Running time is O(n).
void erase (size_t i)
 Removes the ith element from the array. Running time is O(n).
void pop_back ()
 Clears the last element of the array. Running time is O(1).
void pop_back_pod ()
 Clears the last element of the array.
void clear ()
 Removes all elements in the array. Running time is O(n).
void clear_pod ()
 Clears the whole Array by simply marking the size to 0.
void reserve (size_t newSize)
 Enlarges the allocated memory area if it's not big enough to hold newSize elements.

Detailed Description

template<typename T, typename AllocT>
class kNet::Array< T, AllocT >

std::vector -equivalent.


Member Function Documentation

template<typename T, typename AllocT>
size_t kNet::Array< T, AllocT >::size (  )  const [inline]
Returns:
The number of elements in the container.
template<typename T, typename AllocT>
size_t kNet::Array< T, AllocT >::capacity (  )  const [inline]
Returns:
The number of elements that the container can hold without needing to reserve more.
template<typename T, typename AllocT>
AllocT* kNet::Array< T, AllocT >::get_allocator (  )  const [inline]
Returns:
The allocator used by this Array, or 0 if none was set.
template<typename T, typename AllocT>
iterator kNet::Array< T, AllocT >::begin (  )  [inline]
Returns:
An iterator to start of the data.
template<typename T, typename AllocT>
iterator kNet::Array< T, AllocT >::end (  )  [inline]
Returns:
A const pointer to start of the data.
An iterator to past the last element in the array.
template<typename T, typename AllocT>
const T* kNet::Array< T, AllocT >::end (  )  const [inline]
Returns:
A const pointer to past the last element in the array.
template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::push_back_unsafe ( const T &  val  )  [inline]

Inserts the given element to back of the Array, but without doing bounds checking.

Call this function only if you know there is enough capacity in the Array.

template<typename T, typename AllocT>
T& kNet::Array< T, AllocT >::push_back_unsafe_pod (  )  [inline]

Inserts an uninitialized value to the back of the Array, and returns a reference to it.

This function was implemented after profiling a code generation issue with VS2008 that resulted in suboptimal performance.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::erase ( int  start,
int  end 
) [inline]

Erases a range of elements, excluding the element at index end.

That is, the interval [start, end[. Running time is O(n).

<

Todo:
Placement new/delete instead of this crap.

Referenced by kNet::Array< NetworkMessage * >::erase().

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::erase ( size_t  i  )  [inline]

Removes the ith element from the array. Running time is O(n).

<

Todo:
Placement new/delete instead of this crap.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::pop_back (  )  [inline]

Clears the last element of the array. Running time is O(1).

<

Todo:
Placement new/delete instead of this crap.
Note:
Doesn't call destructor for the popped object.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::pop_back_pod (  )  [inline]

Clears the last element of the array.

Running time is O(1). Use for pod data that don't need to be cleared when uninitializing.

Note:
Doesn't call destructor for the popped object.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::clear (  )  [inline]

Removes all elements in the array. Running time is O(n).

<

Todo:
Placement new/delete instead of this crap.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::clear_pod (  )  [inline]

Clears the whole Array by simply marking the size to 0.

Running time is O(1). Only call this function if the element type is a POD that does not need its dtor to be called for cleanup.

template<typename T, typename AllocT>
void kNet::Array< T, AllocT >::reserve ( size_t  newSize  )  [inline]

Enlarges the allocated memory area if it's not big enough to hold newSize elements.

\ todo

Referenced by kNet::Array< NetworkMessage * >::insert(), and kNet::Array< NetworkMessage * >::push_back().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines