Support Forum G3D Web Page |
Dynamic 1D array tuned for performance.
More...
Classes | |
class | DefaultComparator |
Uses < and == to evaluate operator(); this is the default comparator for Array::partition. More... | |
Public Types | |
typedef ConstIterator | const_iterator |
stl porting compatibility helper More... | |
typedef const T * | ConstIterator |
G3D C++ STL style const iterator in same style as Iterator. More... | |
typedef int | difference_type |
stl porting compatibility helper More... | |
typedef T * | Iterator |
G3D C++ STL style iterator variable. More... | |
typedef Iterator | iterator |
stl porting compatibility helper More... | |
typedef int | size_type |
stl porting compatibility helper More... | |
typedef T | value_type |
stl porting compatibility helper More... | |
Public Member Functions | |
Array () | |
Creates a zero length array (no heap allocation occurs until resize). More... | |
Array (const T &v0) | |
Creates an array containing v0. More... | |
Array (const T &v0, const T &v1) | |
Creates an array containing v0 and v1. More... | |
Array (const T &v0, const T &v1, const T &v2) | |
Creates an array containing v0...v2. More... | |
Array (const T &v0, const T &v1, const T &v2, const T &v3) | |
Creates an array containing v0...v3. More... | |
Array (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4) | |
Creates an array containing v0...v4. More... | |
Array (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5) | |
Creates an array containing v0...v5. More... | |
Array (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6) | |
Creates an array containing v0...v6. More... | |
Array (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6, const T &v7) | |
Creates an array containing v0...v7. More... | |
Array (std::initializer_list< T > args) | |
Creates an array containing any number of arguments using curly braces. More... | |
Array (const Array &other) | |
Copy constructor. More... | |
Array (const std::vector< T > &other) | |
~Array () | |
Destructor does not delete() the objects if T is a pointer type (e.g. More... | |
void | append (const T &value) |
Add an element to the end of the array. More... | |
void | append (const T &v1, const T &v2) |
void | append (const T &v1, const T &v2, const T &v3) |
void | append (const T &v1, const T &v2, const T &v3, const T &v4) |
void | append (const T &v1, const T &v2, const T &v3, const T &v4, const T &v5) |
void | append (const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6) |
void | append (const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6, const T &v7) |
template<class S > | |
void | append (const Array< S > &array) |
Append the elements of array. More... | |
void | appendPOD (const Array< T > &other) |
Resizes this to just barely match the size of other + itself and then copies the data to the end of the array from other using memcpy. More... | |
T & | back () |
"The member function returns a reference to the last element of the controlled sequence, which must be non-empty. More... | |
const T & | back () const |
"The member function returns a reference to the last element of the controlled sequence, which must be non-empty. More... | |
Iterator | begin () |
C++ STL style iterator method. More... | |
ConstIterator | begin () const |
int | capacity () const |
"The member function returns the storage currently allocated to hold the controlled
sequence, a value at least as large as size()" For compatibility with std::vector. More... | |
void | clear (bool shrink=true) |
Removes all elements. More... | |
void | clearAndSetMemoryManager (const shared_ptr< MemoryManager > &m) |
bool | contains (const T &e) const |
Returns true if the given element is in the array. More... | |
void | copyFrom (const Array< T > &other) |
void | copyPOD (const Array< T > &other) |
Resizes this to match the size of other and then copies the data from other using memcpy. More... | |
ConstIterator | end () const |
C++ STL style iterator method. More... | |
Iterator | end () |
void | fastClear () |
resize(0, false) More... | |
void | fastRemove (int index, bool shrinkIfNecessary=false) |
Swaps element index with the last element in the array then shrinks the array by one. More... | |
template<class S > | |
Iterator | find (const S &value) |
Finds an element and returns the iterator to it. More... | |
template<class S > | |
ConstIterator | find (const S &value) const |
template<class S > | |
int | findIndex (const S &value) const |
Returns the index of (the first occurance of) an index or -1 if not found. More... | |
T & | first () |
Returns element firstIndex(), performing a check in debug mode to ensure that there is at least one. More... | |
const T & | first () const |
int | firstIndex () const |
T & | front () |
"The member function returns a reference to the first element of the controlled sequence, which must be non-empty. More... | |
const T & | front () const |
"The member function returns a reference to the first element of the controlled sequence, which must be non-empty. More... | |
T * | getCArray () |
The array returned is only valid until the next append() or resize call, or the Array is deallocated. More... | |
const T * | getCArray () const |
The array returned is only valid until the next append() or resize call, or the Array is deallocated. More... | |
void | insert (int n, const T &value) |
Inserts at the specified index and shifts all other elements up by one. More... | |
void | invokeDeleteOnAllElements () |
Calls delete on all objects[0...size-1] and sets the size to zero. More... | |
const T & | last () const |
Returns the last element, performing a check in debug mode that there is at least one element. More... | |
T & | last () |
Returns element lastIndex() More... | |
int | lastIndex () const |
Returns size() - 1 More... | |
int | length () const |
Number of elements in the array. More... | |
template<typename Comparator > | |
void | medianPartition (Array< T > <Median, Array< T > &eqMedian, Array< T > >Median, Array< T > &tempArray, const Comparator &comparator) const |
Paritions the array into those below the median, those above the median, and those elements equal to the median in expected O(n) time using quickselect. More... | |
void | medianPartition (Array< T > <Median, Array< T > &eqMedian, Array< T > >Median) const |
Computes a median partition using the default comparator and a dynamically allocated temporary working array. More... | |
shared_ptr< MemoryManager > | memoryManager () const |
const T & | middle () const |
Returns element middleIndex() More... | |
T & | middle () |
Returns element middleIndex() More... | |
int | middleIndex () const |
Returns iFloor(size() / 2), throws an assertion in debug mode if the array is empty. More... | |
T & | next () |
Pushes a new element onto the end and returns its address. More... | |
T & | next (DoNotInitialize dni) |
Returns a pointer to memory for the next element, invoking either its DoNotInitialize constructor for performance, or its default constructor if the array needs to be resized anyway. More... | |
Array & | operator= (const Array &other) |
Assignment operator. More... | |
Array & | operator= (const std::vector< T > &other) |
T & | operator[] (int n) |
Performs bounds checks in debug mode More... | |
T & | operator[] (uint32 n) |
T & | operator[] (size_t n) |
T & | operator[] (uint64 n) |
const T & | operator[] (int n) const |
Performs bounds checks in debug mode More... | |
const T & | operator[] (uint32 n) const |
const T & | operator[] (size_t n) const |
const T & | operator[] (uint64 n) const |
template<typename Comparator > | |
void | partition (const T &partitionElement, Array< T > <Array, Array< T > &eqArray, Array< T > >Array, const Comparator &comparator) const |
The output arrays are resized with fastClear() so that if they are already of the same size as this array no memory is allocated during partitioning. More... | |
void | partition (const T &partitionElement, Array< T > <Array, Array< T > &eqArray, Array< T > >Array) const |
Uses < and == on elements to perform a partition. More... | |
T | pop (bool shrinkUnderlyingArrayIfNecessary=true) |
Removes the last element and returns it. More... | |
void | pop_back () |
"The member function removes the last element of the controlled sequence, which must be non-empty." For compatibility with std::vector. More... | |
void | popDiscard (bool shrinkUnderlyingArrayIfNecessary=false) |
Pops the last element and discards it without returning anything. More... | |
void | push (const T &value) |
Pushes an element onto the end (appends) More... | |
void | push (const Array< T > &array) |
void | push_back (const T &v) |
Alias to provide std::vector compatibility. More... | |
T & | randomElement () |
const T & | randomElement () const |
void | randomize () |
Redistributes the elements so that the new order is statistically independent of the original order. More... | |
void | randomize (Random &rng) |
Redistributes the elements so that the new order is statistically independent of the original order. More... | |
template<class B > | |
void | randomize (Array< B > &b, Random &rng) |
Redistributes the elements so that the new order is statistically independent of the original order. More... | |
void | remove (Iterator element, int count=1) |
Removes count elements from the array referenced either by index or Iterator. More... | |
void | remove (int index, int count=1) |
void | removeNulls () |
Remove all nullptr elements in linear time without affecting order of the other elements. More... | |
void | reserve (int n) |
Ensures that future append() calls can grow up to size n without allocating memory. More... | |
void | resize (size_t n, bool shrinkIfNecessary=true) |
void | reverse () |
Reverse the elements of the array in place. More... | |
template<class S > | |
int | rfindIndex (const S &value) const |
Returns the index of (the first occurance of) an index or -1 if not found. More... | |
void | setAll (const T &value) |
Sets all elements currently in the array to. More... | |
int | size () const |
Number of elements in the array. More... | |
size_t | sizeInMemory () const |
Number of bytes used by the array object and the memory allocated for it's data pointer. More... | |
template<class LessThan > | |
void | sort (const LessThan &lessThan) |
Sort using a specific less-than function, e.g. More... | |
void | sort (int direction=SORT_INCREASING) |
Sorts the array in increasing order using the > or < operator. More... | |
void | sortSubArray (int beginIndex, int endIndex, int direction=SORT_INCREASING) |
Sorts elements beginIndex through and including endIndex. More... | |
void | sortSubArray (int beginIndex, int endIndex, bool(*lessThan)(const T &elem1, const T &elem2)) |
template<typename StrictWeakOrdering > | |
void | sortSubArray (int beginIndex, int endIndex, StrictWeakOrdering &lessThan) |
The StrictWeakOrdering can be either a class that overloads the function call operator() or a function pointer of the form bool (*lessThan)(const T& elem1, const T& elem2) More... | |
void | swap (Array< T > &str) |
"The member function swaps the controlled sequences between *this and str." Note that this is slower than the optimal std implementation. More... | |
void | trimToSize () |
Resize this array to consume exactly the capacity required by its size. More... | |
Static Public Member Functions | |
static void | swap (Array< T, MIN_ELEMENTS > &a, Array< T, MIN_ELEMENTS > &b) |
Exchanges all data between the two arrays, which are required to have a common MemoryManager. More... | |
Dynamic 1D array tuned for performance.
Objects must have a default constructor (constructor that takes no arguments) in order to be used with this template. You will get the error "no appropriate default constructor found" if they do not.
Do not use with objects that overload placement operator new
, since the speed of Array is partly due to pooled allocation.
Array is highly optimized compared to std::vector.
Array operations are less expensive than on std::vector and for large amounts of data, Array consumes only 1.5x the total size of the data, while std::vector consumes 2.0x. The default array takes up zero heap space. The first resize (or append) operation grows it to a reasonable internal size so it is efficient to append to small arrays.
Then Array needs to copy data internally on a resize operation it correctly invokes copy constructors of the elements (the MSVC6 implementation of std::vector uses realloc, which can create memory leaks for classes containing references and pointers). Array provides a guaranteed safe way to access the underlying data as a flat C array – Array::getCArray. Although (T*)std::vector::begin() can be used for this purpose, it is not guaranteed to succeed on all platforms.
To serialize an array, see G3D::serialize.
The template parameter MIN_ELEMENTS indicates the smallest number of elements that will be allocated. The default of 10 is designed to avoid the overhead of repeatedly allocating the array as it grows from 1, to 2, and so on. If you are creating a lot of small Arrays, however, you may want to set this smaller to reduce the memory cost. Once the array has been allocated, it will never deallocate the underlying array unless MIN_ELEMENTS is set to 0, MIN_BYTES is 0, and the array is empty.
Do not subclass an Array.
typedef ConstIterator G3D::Array< T, MIN_ELEMENTS >::const_iterator |
stl porting compatibility helper
typedef const T* G3D::Array< T, MIN_ELEMENTS >::ConstIterator |
G3D C++ STL style const iterator in same style as Iterator.
typedef int G3D::Array< T, MIN_ELEMENTS >::difference_type |
stl porting compatibility helper
typedef T* G3D::Array< T, MIN_ELEMENTS >::Iterator |
typedef Iterator G3D::Array< T, MIN_ELEMENTS >::iterator |
stl porting compatibility helper
typedef int G3D::Array< T, MIN_ELEMENTS >::size_type |
stl porting compatibility helper
typedef T G3D::Array< T, MIN_ELEMENTS >::value_type |
stl porting compatibility helper
|
inline |
Creates a zero length array (no heap allocation occurs until resize).
|
inlineexplicit |
Creates an array containing v0.
|
inline |
Creates an array containing v0 and v1.
|
inline |
Creates an array containing v0...v2.
|
inline |
Creates an array containing v0...v3.
|
inline |
Creates an array containing v0...v4.
|
inline |
Creates an array containing v0...v5.
|
inline |
Creates an array containing v0...v6.
|
inline |
Creates an array containing v0...v7.
|
inline |
Creates an array containing any number of arguments using curly braces.
For example,
Array<int> {5, 10, 3, 4, 1}
|
inline |
Copy constructor.
Copying arrays is slow...perhaps you want to pass a reference or a pointer instead?
|
inlineexplicit |
|
inline |
Destructor does not delete() the objects if T is a pointer type (e.g.
T = int*) instead, it deletes the pointers themselves and leaves the objects. Call deleteAll if you want to dealocate the objects referenced. Do not call deleteAll if T
is not a pointer type (e.g. do call Array<Foo*>::deleteAll, do not call Array<Foo>::deleteAll).
|
inline |
Add an element to the end of the array.
Will not shrink the underlying array under any circumstances. It is safe to append an element that is already in the array.
Referenced by G3D::Spline< UprightFrame >::append(), G3D::Array< G3D::AABox >::append(), G3D::GLFWWindow::appendFileToFileList(), G3D::Array< G3D::AABox >::copyFrom(), G3D::Pathfinder< Node, HashFunc >::findPath(), G3D::ArticulatedModel::getAnimationNames(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::Node::getHandles(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::Node::getHandles(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::Node::getIntersectingMembers(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::Node::getIntersectingMembers(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::getIntersectingMembers(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::getIntersectingMembers(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getKeys(), G3D::Table< String, double >::getKeys(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::getMembers(), G3D::WeakCache< G3D::Sampler, shared_ptr< G3D::GLSamplerObject > >::getValues(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getValues(), G3D::Table< String, double >::getValues(), G3D::FastPointHashGrid< Value, PosFunc >::insert(), G3D::Array< G3D::AABox >::medianPartition(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::operator=(), G3D::Array< G3D::AABox >::partition(), G3D::SmallArray< G3D::Vector4, 8 >::push(), G3D::Array< G3D::AABox >::push(), G3D::AudioDevice::WeakCleanupArray< G3D::Sound >::remember(), G3D::OrderedTable< Key, Value >::set(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::SmallTable(), G3D::Spline< UprightFrame >::Spline(), and G3D::Welder::weld().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Append the elements of array.
Cannot be called with this array as an argument.
Can append elements of any array that are implicitly convertable (e.g., pointers to subclass instances) to type T.
|
inline |
Resizes this to just barely match the size of other + itself and then copies the data to the end of the array from other using memcpy.
This is only safe for POD types
Referenced by G3D::Args::setMultiDrawArrays().
|
inline |
"The member function returns a reference to the last element of the controlled sequence, which must be non-empty.
" For compatibility with std::vector.
|
inline |
"The member function returns a reference to the last element of the controlled sequence, which must be non-empty.
" For compatibility with std::vector.
|
inline |
C++ STL style iterator method.
Returns the first iterator element. Do not change the size of the array while iterating.
Referenced by G3D::Array< G3D::AABox >::remove().
|
inline |
|
inline |
"The member function returns the storage currently allocated to hold the controlled sequence, a value at least as large as size()" For compatibility with std::vector.
Referenced by G3D::Array< G3D::AABox >::trimToSize().
|
inline |
Removes all elements.
Use resize(0, false) or fastClear if you want to remove all elements without deallocating the underlying array so that future append() calls will be faster.
Referenced by G3D::AudioDevice::WeakCleanupArray< G3D::Sound >::cleanup(), G3D::CPUVertexArray::clear(), G3D::OrderedTable< Key, Value >::clear(), G3D::Spline< UprightFrame >::clear(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::clear(), G3D::Array< G3D::AABox >::clearAndSetMemoryManager(), G3D::Rect2D::clip(), G3D::Array< G3D::AABox >::fastClear(), and G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::makeNode().
|
inline |
|
inline |
Returns true if the given element is in the array.
Referenced by G3D::SmallArray< G3D::Vector4, 8 >::contains(), and G3D::BlockPoolMemoryManager::free().
|
inline |
|
inline |
Resizes this to match the size of other and then copies the data from other using memcpy.
This is only safe for POD types
|
inline |
C++ STL style iterator method.
Returns one after the last valid iterator element.
Referenced by G3D::Array< G3D::AABox >::find(), and G3D::Array< G3D::AABox >::remove().
|
inline |
|
inline |
resize(0, false)
Referenced by G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::balance(), G3D::GLFWWindow::clearDroppedFileList(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::fastClear(), G3D::Pathfinder< Node, HashFunc >::findPath(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::makeNode(), G3D::Array< G3D::AABox >::medianPartition(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::operator=(), G3D::Array< G3D::AABox >::partition(), and G3D::Args::setMultiDrawArrays().
|
inline |
Swaps element index with the last element in the array then shrinks the array by one.
Referenced by G3D::SmallArray< G3D::Vector4, 8 >::fastRemove(), G3D::PathTracer::BufferSet::fastRemove(), G3D::OrderedTable< Key, Value >::fastRemoveKey(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::makeNode(), G3D::AudioDevice::WeakCleanupArray< G3D::Sound >::remember(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::remove(), and G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::remove().
|
inline |
Finds an element and returns the iterator to it.
If the element isn't found then returns end().
|
inline |
|
inline |
Returns the index of (the first occurance of) an index or -1 if not found.
Referenced by G3D::SmallArray< G3D::Vector4, 8 >::findIndex(), and G3D::VideoRecordDialog::setScreenShotFormat().
|
inline |
Returns element firstIndex(), performing a check in debug mode to ensure that there is at least one.
Referenced by G3D::OrderedTable< Key, Value >::fastRemoveKey(), G3D::OrderedTable< Key, Value >::key(), G3D::Array< G3D::AABox >::medianPartition(), and G3D::OrderedTable< Key, Value >::removeKey().
|
inline |
|
inline |
|
inline |
"The member function returns a reference to the first element of the controlled sequence, which must be non-empty.
" For compatibility with std::vector.
|
inline |
"The member function returns a reference to the first element of the controlled sequence, which must be non-empty.
" For compatibility with std::vector.
|
inline |
The array returned is only valid until the next append() or resize call, or the Array is deallocated.
Referenced by G3D::Array< G3D::AABox >::Array(), G3D::AttributeArray::AttributeArray(), G3D::cyclicCatmullRomSpline(), G3D::Map2D< Color1, Color1 >::flipHorizontal(), G3D::Map2D< Color1, Color1 >::flipVertical(), G3D::Map2D< Color1, Color1 >::getCArray(), G3D::Array< G3D::AABox >::operator=(), G3D::receive(), G3D::RenderDevice::sendIndices(), G3D::AttributeArray::update(), and G3D::AttributeArray::updateInterleaved().
|
inline |
|
inline |
Inserts at the specified index and shifts all other elements up by one.
|
inline |
Calls delete on all objects[0...size-1] and sets the size to zero.
Referenced by G3D::BlockPoolMemoryManager::~BlockPoolMemoryManager().
|
inline |
Returns the last element, performing a check in debug mode that there is at least one element.
Referenced by G3D::BlockPoolMemoryManager::alloc(), G3D::Spline< UprightFrame >::append(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::closed(), G3D::Spline< UprightFrame >::getControl(), G3D::Spline< UprightFrame >::hashCode(), G3D::Array< G3D::AABox >::medianPartition(), G3D::Array< G3D::AABox >::next(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator T*(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator T*(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator->(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator->(), G3D::Array< G3D::AABox >::remove(), and G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::vertex().
|
inline |
Returns element lastIndex()
|
inline |
Returns size() - 1
|
inline |
Number of elements in the array.
(Same as size; this is just here for convenience).
Referenced by G3D::AudioDevice::WeakCleanupArray< G3D::Sound >::cleanup(), G3D::Matrix::fromDiagonal(), G3D::ConvexPolygon::normal(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator==(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator==(), G3D::AudioDevice::WeakCleanupArray< G3D::Sound >::remember(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::remove(), and G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::remove().
|
inline |
Paritions the array into those below the median, those above the median, and those elements equal to the median in expected O(n) time using quickselect.
If the array has an even number of different elements, the median for partition purposes is the largest value less than the median.
tempArray | used for working scratch space |
comparator | see parition() for a discussion. |
Referenced by G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::makeNode(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::makeNode(), and G3D::Array< G3D::AABox >::medianPartition().
|
inline |
Computes a median partition using the default comparator and a dynamically allocated temporary working array.
If the median is not in the array, it is chosen to be the largest value smaller than the true median.
|
inline |
Referenced by G3D::Array< G3D::AABox >::swap().
|
inline |
Returns element middleIndex()
Referenced by G3D::Array< G3D::AABox >::medianPartition().
|
inline |
Returns element middleIndex()
|
inline |
Returns iFloor(size() / 2), throws an assertion in debug mode if the array is empty.
|
inline |
Pushes a new element onto the end and returns its address.
This is the same as A.resize(A.size() + 1, false); A.last()
Referenced by G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getCreateEntry(), and G3D::SmallArray< G3D::Vector4, 8 >::next().
|
inline |
Returns a pointer to memory for the next element, invoking either its DoNotInitialize constructor for performance, or its default constructor if the array needs to be resized anyway.
If T does not have a DoNotInitialize constructor then this will fail at compile time.
|
inline |
Assignment operator.
Will be private in a future release because this is slow and can be invoked by accident by novice C++ programmers. If you really want to copy an Array, use the explicit copy constructor.
|
inline |
|
inline |
Performs bounds checks in debug mode
|
inline |
|
inline |
|
inline |
|
inline |
Performs bounds checks in debug mode
|
inline |
|
inline |
|
inline |
|
inline |
The output arrays are resized with fastClear() so that if they are already of the same size as this array no memory is allocated during partitioning.
comparator | A function, or class instance with an overloaded operator() that compares two elements of type T and returns 0 if they are equal, -1 if the second is smaller, and 1 if the first is smaller (i.e., following the conventions of String::compare). For example: |
int compare(int A, int B) { if (A < B) { return 1; } else if (A == B) { return 0; } else { return -1; } }
Referenced by G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::makeNode(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::makeNode(), G3D::Array< G3D::AABox >::medianPartition(), and G3D::Array< G3D::AABox >::partition().
|
inline |
Uses < and == on elements to perform a partition.
See partition().
|
inline |
Removes the last element and returns it.
By default, shrinks the underlying array.
Referenced by G3D::BlockPoolMemoryManager::alloc(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::clearData(), G3D::SmallArray< G3D::Vector4, 8 >::fastRemove(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::SmallArray< G3D::Vector4, 8 >::pop(), G3D::Array< G3D::AABox >::pop_back(), and G3D::TextInput::popSettings().
|
inline |
"The member function removes the last element of the controlled sequence, which must be non-empty." For compatibility with std::vector.
|
inline |
Pops the last element and discards it without returning anything.
Faster than pop. By default, does not shrink the underlying array.
Referenced by G3D::SmallArray< G3D::Vector4, 8 >::popDiscard().
|
inline |
Pushes an element onto the end (appends)
Referenced by G3D::BlockPoolMemoryManager::alloc(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::clearData(), G3D::BlockPoolMemoryManager::free(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::BoxIntersectionIterator::operator++(), G3D::Array< G3D::AABox >::push_back(), and G3D::TextInput::pushSettings().
|
inline |
|
inline |
Alias to provide std::vector compatibility.
|
inline |
|
inline |
|
inline |
Redistributes the elements so that the new order is statistically independent of the original order.
O(n) time.
Referenced by G3D::Array< G3D::AABox >::randomize().
|
inline |
Redistributes the elements so that the new order is statistically independent of the original order.
O(n) time.
|
inline |
Redistributes the elements so that the new order is statistically independent of the original order.
O(n) time. Randomizes both arrays in the same way.
|
inline |
Removes count elements from the array referenced either by index or Iterator.
Referenced by G3D::OrderedTable< Key, Value >::removeKey().
|
inline |
|
inline |
Remove all nullptr elements in linear time without affecting order of the other elements.
|
inline |
Ensures that future append() calls can grow up to size n without allocating memory.
Referenced by G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getCreateEntry(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::getMembers(), and G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::setSizeHint().
|
inline |
shrinkIfNecessary | if false, memory will never be reallocated when the array shrinks. This makes resizing much faster but can waste memory. Default = true. |
Referenced by G3D::Array< G3D::AABox >::append(), G3D::Array< G3D::AABox >::clear(), G3D::Array< G3D::AABox >::copyFrom(), G3D::deserialize(), G3D::Array< G3D::AABox >::fastRemove(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getKeys(), G3D::Table< String, double >::getKeys(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getValues(), G3D::Table< String, double >::getValues(), G3D::Spline< UprightFrame >::init(), G3D::Array< G3D::AABox >::insert(), G3D::Array< G3D::AABox >::invokeDeleteOnAllElements(), G3D::Array< G3D::AABox >::next(), G3D::Array< G3D::AABox >::operator=(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::PolyLineGeneric(), G3D::Array< G3D::AABox >::pop(), G3D::Array< G3D::AABox >::popDiscard(), G3D::Array< G3D::AABox >::remove(), G3D::Array< G3D::AABox >::removeNulls(), G3D::Array< G3D::AABox >::reserve(), G3D::SmallArray< G3D::Vector4, 8 >::resize(), G3D::PathTracer::BufferSet::resize(), G3D::ConvexPolygon::setNumVertices(), and G3D::MeshAlg::toIndexedTriList().
|
inline |
Reverse the elements of the array in place.
Referenced by G3D::Pathfinder< Node, HashFunc >::findPath().
|
inline |
Returns the index of (the first occurance of) an index or -1 if not found.
Searches from the right.
|
inline |
Sets all elements currently in the array to.
value |
|
inline |
Number of elements in the array.
Referenced by G3D::BlockPoolMemoryManager::alloc(), G3D::Spline< UprightFrame >::append(), G3D::AttributeArray::AttributeArray(), G3D::Array< G3D::AABox >::back(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::clearData(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::closed(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::computeBounds(), G3D::Array< G3D::AABox >::contains(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::containsKey(), G3D::AttributeArray::createInterleaved(), G3D::cyclicCatmullRomSpline(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::deleteKeys(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::deleteValues(), G3D::deserialize(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::distance(), G3D::Spline< UprightFrame >::evaluate(), G3D::PathTracer::BufferSet::fastRemove(), G3D::Array< G3D::AABox >::fastRemove(), G3D::OrderedTable< Key, Value >::fastRemoveKey(), G3D::OrderedTable< Key, Value >::findIndexOfValue(), G3D::BlockPoolMemoryManager::freeListNumBlocks(), G3D::Spline< UprightFrame >::getControl(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getCreateEntry(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::getIntersectingMembers(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getKeys(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::getMembers(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getPointer(), G3D::WeakCache< G3D::Sampler, shared_ptr< G3D::GLSamplerObject > >::getValues(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getValues(), G3D::Args::hasGPUIndexStream(), G3D::Spline< UprightFrame >::hashCode(), G3D::Spline< UprightFrame >::init(), G3D::FastPointHashGrid< Value, PosFunc >::insert(), G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::insert(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::insert(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::insert(), G3D::Array< G3D::AABox >::length(), G3D::PointKDTree< T, PositionFunc, HashFunc, EqualsFunc >::makeNode(), G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::makeNode(), G3D::Array< G3D::AABox >::medianPartition(), G3D::XML::numChildren(), G3D::PhysicsFrameSplineEditor::numControlPoints(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::numSegments(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::numVertices(), G3D::ConvexPolygon::numVertices(), G3D::ConvexPolygon2D::numVertices(), G3D::Discovery::Server::ok(), G3D::FastPointHashGrid< Value, PosFunc >::Iterator::operator++(), G3D::FastPointHashGrid< Value, PosFunc >::BoxIterator::operator++(), G3D::SmallArray< G3D::Vector4, 8 >::operator=(), G3D::Array< G3D::AABox >::operator=(), G3D::Spline< UprightFrame >::operator==(), G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::PointHashGrid(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::PolyLineGeneric(), G3D::Array< G3D::AABox >::randomize(), G3D::receive(), G3D::OrderedTable< Key, Value >::removeKey(), G3D::Array< G3D::AABox >::removeNulls(), G3D::Array< G3D::AABox >::reserve(), G3D::send(), G3D::RenderDevice::sendIndices(), G3D::serialize(), G3D::OrderedTable< Key, Value >::set(), G3D::Map2D< Color1, Color1 >::setAll(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::setSizeHint(), G3D::IconSet::size(), G3D::CPUVertexArray::size(), G3D::OrderedTable< Key, Value >::size(), G3D::Spline< UprightFrame >::size(), G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::size(), G3D::UprightSplineManipulator::splineSize(), G3D::MeshAlg::toIndexedTriList(), G3D::ArticulatedModel::Mesh::triangleCount(), G3D::Array< G3D::AABox >::trimToSize(), G3D::AttributeArray::update(), G3D::AttributeArray::updateInterleaved(), G3D::_internal::PolyLineGeneric< SegmentType, VertexType >::vertex(), and G3D::ConvexPolygon2D::vertex().
|
inline |
Number of bytes used by the array object and the memory allocated for it's data pointer.
Does not include the memory of objects pointed to by objects in the data array
|
inline |
Sort using a specific less-than function, e.g.
:
Note that for pointer arrays, the const
must come after the class name, e.g., Array<MyClass*>
uses:
or a functor, e.g.,
|
inline |
Sorts the array in increasing order using the > or < operator.
To invoke this method on Array<T>, T must override those operator. You can overide these operators as follows:
|
inline |
Sorts elements beginIndex through and including endIndex.
|
inline |
|
inline |
The StrictWeakOrdering can be either a class that overloads the function call operator() or a function pointer of the form bool (*lessThan)(const T& elem1, const T& elem2)
|
inlinestatic |
Exchanges all data between the two arrays, which are required to have a common MemoryManager.
This is a convenient way to avoid large array copies when handing off data without involving reference counting or manual memory management. Beware that pointers or references into the arrays will access memory in the other array after the swap.
|
inline |
"The member function swaps the controlled sequences between *this and str." Note that this is slower than the optimal std implementation.
For compatibility with std::vector.
|
inline |