ArrayList< TElem > Class Template Reference

A typical multi-purpose, resizable array, coded with an emphasis on speed. More...

List of all members.

Public Types

typedef TElem Elem
 An accessible typedef for the elements in the array.
typedef TElem Elem
 An accessible typedef for the elements in the array.

Public Member Functions

ElemAddBack (index_t inc=1)
ElemAddBack (index_t inc=1)
ElemAddBackItem (const Elem &elem)
ElemAddBackItem (const Elem &elem)
ElemAddBackUnconstructed (index_t inc=1)
ElemAddBackUnconstructed (index_t inc=1)
void AppendCopy (const ArrayList &src)
 Adds copies of each element in a source ArrayList to the end of an ArrayList.
void AppendCopy (const Elem *src, index_t size)
 Adds copies of each element in an array to the end of an ArrayList.
void AppendCopy (const ArrayList &src)
 Adds copies of each element in a source ArrayList to the end of an ArrayList.
void AppendCopy (const Elem *src, index_t size)
 Adds copies of each element in an array to the end of an ArrayList.
void AppendSteal (ArrayList *src)
 Moves the elements in a source ArrayList to the end of an ArrayList, converting the source into a sub-alias.
void AppendSteal (ArrayList *src)
 Moves the elements in a source ArrayList to the end of an ArrayList, converting the source into a sub-alias.
Elemback ()
const Elemback () const
 Get the last element in the array, as in *(a.end() - 1).
Elemback ()
const Elemback () const
 Get the last element in the array, as in *(a.end() - 1).
Elembegin ()
const Elembegin () const
 Get a pointer to the beginning of the array.
Elembegin ()
const Elembegin () const
 Get a pointer to the beginning of the array.
index_t capacity () const
 The allocated number of elements, or -1 if alias.
index_t capacity () const
 The allocated number of elements, or -1 if alias.
void Clear ()
 Zeroes the size of an ArrayList and frees its memory.
void Clear ()
 Zeroes the size of an ArrayList and frees its memory.
void Copy (const Elem *src, index_t size)
void Copy (const Elem *src, index_t size)
void Destruct ()
void Destruct ()
bool empty () const
 Whether the ArrayList is empty (size 0).
bool empty () const
 Whether the ArrayList is empty (size 0).
Elemend ()
const Elemend () const
 Get a pointer to just past the end of the array.
Elemend ()
const Elemend () const
 Get a pointer to just past the end of the array.
void EnsureSizeAtLeast (index_t size)
void EnsureSizeAtLeast (index_t size)
void ExtractAppend (index_t pos, index_t size, ArrayList *dest)
 Moves multiple elements from a given position in an ArrayList to the end of another ArrayList.
void ExtractAppend (index_t pos, index_t size, ArrayList *dest)
 Moves multiple elements from a given position in an ArrayList to the end of another ArrayList.
void ExtractInit (index_t pos, index_t size, ArrayList *dest)
 Moves multiple elements from a given position in an ArrayList to a new ArrayList.
void ExtractInit (index_t pos, index_t size, Elem *dest)
 Moves multiple elements from a given position in an ArrayList to a given location.
void ExtractInit (index_t pos, index_t size, ArrayList *dest)
 Moves multiple elements from a given position in an ArrayList to a new ArrayList.
void ExtractInit (index_t pos, index_t size, Elem *dest)
 Moves multiple elements from a given position in an ArrayList to a given location.
Elemfront ()
const Elemfront () const
 Get the first element in the array, as in *a.begin().
Elemfront ()
const Elemfront () const
 Get the first element in the array, as in *a.begin().
void GrowTo (index_t size)
 Increases an ArrayList's size, increasing capacity if needed, and default constructs newly added elements.
void GrowTo (index_t size)
 Increases an ArrayList's size, increasing capacity if needed, and default constructs newly added elements.
void InfixCopy (index_t pos, const ArrayList &src)
 Adds copies of each element in a source ArrayList at a given position in an ArrayList.
void InfixCopy (index_t pos, const Elem *src, index_t size)
 Adds copies of each element in an array at a given position in an ArrayList.
void InfixCopy (index_t pos, const ArrayList &src)
 Adds copies of each element in a source ArrayList at a given position in an ArrayList.
void InfixCopy (index_t pos, const Elem *src, index_t size)
 Adds copies of each element in an array at a given position in an ArrayList.
void InfixSteal (index_t pos, ArrayList *src)
 Moves the elements in a source ArrayList to a given position in an ArrayList, converting the source into a sub-alias.
void InfixSteal (index_t pos, ArrayList *src)
 Moves the elements in a source ArrayList to a given position in an ArrayList, converting the source into a sub-alias.
void Init (index_t size)
void Init (index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), default constructing the contents.
void Init ()
 Initializes an empty ArrayList.
void Init (index_t size)
void Init (index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), default constructing the contents.
void Init ()
 Initializes an empty ArrayList.
void InitAlias (Elem *ptr, index_t size)
 Initializes an ArrayList as an alias of an array with a given size.
void InitAlias (Elem *ptr, index_t size)
 Initializes an ArrayList as an alias of an array with a given size.
void InitCopy (const ArrayList &src, index_t cap)
 Initializes an ArrayList to a copy of another ArrayList, but with specified capacity.
void InitCopy (const Elem *src, index_t size)
void InitCopy (const Elem *src, index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), element-wise copying the contents of another array.
void InitCopy (const ArrayList &src, index_t cap)
 Initializes an ArrayList to a copy of another ArrayList, but with specified capacity.
void InitCopy (const Elem *src, index_t size)
void InitCopy (const Elem *src, index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), element-wise copying the contents of another array.
ElemInitRaw (index_t size)
ElemInitRaw (index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size) but does not construct the contents.
ElemInitRaw (index_t size)
ElemInitRaw (index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size) but does not construct the contents.
void InitRepeat (const Elem &elem, index_t size)
void InitRepeat (const Elem &elem, index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), copying some object to each of the elements.
void InitRepeat (const Elem &elem, index_t size)
void InitRepeat (const Elem &elem, index_t size, index_t cap)
 Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), copying some object to each of the elements.
void InitSteal (Elem *ptr, index_t size)
void InitSteal (Elem *ptr, index_t size, index_t cap)
 Initializes an ArrayList directly with an array with a given size and (optionally) capacity (defaults to size).
void InitSteal (Elem *ptr, index_t size)
void InitSteal (Elem *ptr, index_t size, index_t cap)
 Initializes an ArrayList directly with an array with a given size and (optionally) capacity (defaults to size).
void InitSubAlias (const ArrayList &src, index_t pos, index_t size)
 Initializes an ArrayList as an alias of a section of another ArrayList.
void InitSubAlias (const ArrayList &src, index_t pos, index_t size)
 Initializes an ArrayList as an alias of a section of another ArrayList.
void InitSubCopy (const ArrayList &src, index_t pos, index_t size)
void InitSubCopy (const ArrayList &src, index_t pos, index_t size, index_t cap)
 Initializes an ArrayList to a copy of a section of another ArrayList, with (optionally) specified capacity (defaults to the other list's size).
void InitSubCopy (const ArrayList &src, index_t pos, index_t size)
void InitSubCopy (const ArrayList &src, index_t pos, index_t size, index_t cap)
 Initializes an ArrayList to a copy of a section of another ArrayList, with (optionally) specified capacity (defaults to the other list's size).
ElemInsert (index_t pos)
void Insert (index_t pos, index_t inc)
 Adds (optionally) inc elements (default 1) at a given position in an ArrayList, default constructing them.
ElemInsert (index_t pos)
void Insert (index_t pos, index_t inc)
 Adds (optionally) inc elements (default 1) at a given position in an ArrayList, default constructing them.
ElemInsertCopy (index_t pos, const Elem &src)
 Adds a copy of an element at a given position in an ArrayList.
ElemInsertCopy (index_t pos, const Elem &src)
 Adds a copy of an element at a given position in an ArrayList.
ElemInsertRaw (index_t pos, index_t inc=1)
 Adds (optionally) inc elements (default 1) at a given position in an ArrayList, but does not construct them.
ElemInsertRaw (index_t pos, index_t inc=1)
 Adds (optionally) inc elements (default 1) at a given position in an ArrayList, but does not construct them.
index_t length () const
 The number of active elements in the ArrayList.
index_t length () const
 The number of active elements in the ArrayList.
Elemoperator[] (index_t i)
const Elemoperator[] (index_t i) const
 Access an element at position i.
Elemoperator[] (index_t i)
const Elemoperator[] (index_t i) const
 Access an element at position i.
void PopBack (index_t dec=1)
 Removes (optionally) dec elements (default 1) from the end of an ArrayList, destructing them.
void PopBack (index_t dec=1)
 Removes (optionally) dec elements (default 1) from the end of an ArrayList, destructing them.
void PopBackInit (Elem *dest)
 Moves an element from the end of an ArrayList to a given location.
void PopBackInit (Elem *dest)
 Moves an element from the end of an ArrayList to a given location.
ElemPopBackPtr ()
ElemPopBackPtr ()
void PopBackRaw (index_t dec=1)
 Removes (optionally) dec elements (default 1) from the end of an ArrayList, but does not destruct them.
void PopBackRaw (index_t dec=1)
 Removes (optionally) dec elements (default 1) from the end of an ArrayList, but does not destruct them.
ElemPushBack ()
void PushBack (index_t inc)
 Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them.
ElemPushBack ()
void PushBack (index_t inc)
 Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them.
ElemPushBackCopy (const Elem &src)
 Adds a copy of an element to the end of an ArrayList.
ElemPushBackCopy (const Elem &src)
 Adds a copy of an element to the end of an ArrayList.
ElemPushBackRaw (index_t inc=1)
 Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them.
ElemPushBackRaw (index_t inc=1)
 Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them.
ElemReleasePointer ()
ElemReleasePointer ()
ElemReleasePtr ()
 Returns a pointer to the beginning of the ArrayList's array and demotes the ArrayList to an alias (voids deallocation rights).
ElemReleasePtr ()
 Returns a pointer to the beginning of the ArrayList's array and demotes the ArrayList to an alias (voids deallocation rights).
void Remove (index_t pos, index_t dec=1)
 Removes (optionally) dec elements (default 1) from a given position in an ArrayList, destructing them.
void Remove (index_t pos, index_t dec=1)
 Removes (optionally) dec elements (default 1) from a given position in an ArrayList, destructing them.
void RemoveInit (index_t pos, Elem *dest)
 Moves an element from a given position in an ArrayList to a given location.
void RemoveInit (index_t pos, Elem *dest)
 Moves an element from a given position in an ArrayList to a given location.
void RemoveRaw (index_t pos, index_t dec=1)
 Removes (optionally) dec elements (default 1) from a given position in an ArrayList, but does not destruct them.
void RemoveRaw (index_t pos, index_t dec=1)
 Removes (optionally) dec elements (default 1) from a given position in an ArrayList, but does not destruct them.
void Reserve (index_t size)
 Ensures that an ArrayList has capacity greater than a given size.
void Reserve (index_t size)
 Ensures that an ArrayList has capacity greater than a given size.
void Resize (index_t size)
 Changes an ArrayList's size, increasing capacity if needed, and constructing or destructing elements as appropriate.
void Resize (index_t size)
 Changes an ArrayList's size, increasing capacity if needed, and constructing or destructing elements as appropriate.
void SegmentAppend (index_t size, ArrayList *dest)
 Moves multiple elements from the end of an ArrayList to the end of another ArrayList.
void SegmentAppend (index_t size, ArrayList *dest)
 Moves multiple elements from the end of an ArrayList to the end of another ArrayList.
void SegmentInit (index_t size, ArrayList *dest)
 Moves multiple elements from the end of an ArrayList to a new ArrayList.
void SegmentInit (index_t size, Elem *dest)
 Moves multiple elements from the end of an ArrayList to a given location.
void SegmentInit (index_t size, ArrayList *dest)
 Moves multiple elements from the end of an ArrayList to a new ArrayList.
void SegmentInit (index_t size, Elem *dest)
 Moves multiple elements from the end of an ArrayList to a given location.
void ShrinkTo (index_t size)
 Decreases an ArrayList's size, destructing removed elements.
void ShrinkTo (index_t size)
 Decreases an ArrayList's size, destructing removed elements.
index_t size () const
 The number of active elements in the ArrayList.
index_t size () const
 The number of active elements in the ArrayList.
void SizeAtLeast (index_t size)
 Ensures that an ArrayList has at least size active elements, adding and constructing elements as appropriate.
void SizeAtLeast (index_t size)
 Ensures that an ArrayList has at least size active elements, adding and constructing elements as appropriate.
void SizeAtMost (index_t size)
 Ensures that an ArrayList has at most size active elements, destructing and removing elements as appropriate.
void SizeAtMost (index_t size)
 Ensures that an ArrayList has at most size active elements, destructing and removing elements as appropriate.
void Steal (ArrayList *other)
void Steal (const Elem *src, index_t size)
void Steal (ArrayList *other)
void Steal (const Elem *src, index_t size)
void Swap (ArrayList *other)
 Exchanges arrays with another ArrayList.
void Swap (ArrayList *other)
 Exchanges arrays with another ArrayList.
void Trim ()
 Reduces the capacity of an ArrayList to exactly its size.
void Trim ()
 Reduces the capacity of an ArrayList to exactly its size.

Detailed Description

template<typename TElem>
class ArrayList< TElem >

A typical multi-purpose, resizable array, coded with an emphasis on speed.

Also features debug-mode poisoning and bounds-checking.

This class is roughly equivalent to std::vector, but with several important differences. Notably, it relocates objects with a simple bit-copy, which is potentially much faster than std::vector's use of the copy constructor but prevents use with objects that have self-referential points (an uncommon programming practice). Also, ArrayList is fully FASTlib complient and can store all FASTlib complient classes (i.e. those that declare OBJECT_TRAVERSAL) even if they do not have copy constructors.

As with std::vector, it is unwise to use pointers to objects stored by ArrayList unless you know the array will not change for the life-span of the pointer.

Definition at line 84 of file arraylist.h.


Member Typedef Documentation

template<typename TElem>
typedef TElem ArrayList< TElem >::Elem

An accessible typedef for the elements in the array.

Definition at line 87 of file arraylist.h.

template<typename TElem>
typedef TElem ArrayList< TElem >::Elem

An accessible typedef for the elements in the array.

Definition at line 87 of file arraylist.h.


Member Function Documentation

template<typename TElem>
void ArrayList< TElem >::AppendCopy ( const ArrayList< TElem > &  src  )  [inline]

Adds copies of each element in a source ArrayList to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the Arraylist to append
See also:
PushBackCopy, AppendSteal, SegmentInit, InfixCopy

Definition at line 640 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::AppendCopy ( const Elem src,
index_t  size 
) [inline]

Adds copies of each element in an array to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the array of elements to append
size the number of elements to append
See also:
PushBackCopy, SegmentInit, InfixCopy

Definition at line 622 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::AppendCopy ( const ArrayList< TElem > &  src  )  [inline]

Adds copies of each element in a source ArrayList to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the Arraylist to append
See also:
PushBackCopy, AppendSteal, SegmentInit, InfixCopy

Definition at line 640 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::AppendCopy ( const Elem src,
index_t  size 
) [inline]

Adds copies of each element in an array to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the array of elements to append
size the number of elements to append
See also:
PushBackCopy, SegmentInit, InfixCopy

Definition at line 622 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::AppendCopy().

template<typename TElem>
void ArrayList< TElem >::AppendSteal ( ArrayList< TElem > *  src  ) 

Moves the elements in a source ArrayList to the end of an ArrayList, converting the source into a sub-alias.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Given the above, be careful not to AppendSteal from multiple ArrayLists and then expect each of them to alias their respective portions of the created ArrayList.

Parameters:
src the ArrayList to append and steal from
See also:
AppendCopy, InfixSteal
template<typename TElem >
void ArrayList< TElem >::AppendSteal ( ArrayList< TElem > *  src  )  [inline]

Moves the elements in a source ArrayList to the end of an ArrayList, converting the source into a sub-alias.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Given the above, be careful not to AppendSteal from multiple ArrayLists and then expect each of them to alias their respective portions of the created ArrayList.

Parameters:
src the ArrayList to append and steal from
See also:
AppendCopy, InfixSteal

Definition at line 1150 of file arraylist.h.

References ArrayList< TElem >::begin(), mem::Copy(), mem::Free(), ArrayList< TElem >::PushBackRaw(), and ArrayList< TElem >::size().

template<typename TElem>
const Elem& ArrayList< TElem >::back (  )  const [inline]

Get the last element in the array, as in *(a.end() - 1).

Definition at line 1080 of file arraylist.h.

template<typename TElem>
const Elem& ArrayList< TElem >::back (  )  const [inline]

Get the last element in the array, as in *(a.end() - 1).

Definition at line 1080 of file arraylist.h.

Referenced by String::Append(), String::Split(), and String::Terminate().

template<typename TElem>
const Elem* ArrayList< TElem >::begin (  )  const [inline]

Get a pointer to the beginning of the array.

Definition at line 1056 of file arraylist.h.

template<typename TElem>
const Elem* ArrayList< TElem >::begin (  )  const [inline]
template<typename TElem>
index_t ArrayList< TElem >::capacity (  )  const [inline]

The allocated number of elements, or -1 if alias.

Definition at line 1037 of file arraylist.h.

template<typename TElem>
index_t ArrayList< TElem >::capacity (  )  const [inline]

The allocated number of elements, or -1 if alias.

Definition at line 1037 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::InitSubCopy().

template<typename TElem>
void ArrayList< TElem >::Clear (  )  [inline]

Zeroes the size of an ArrayList and frees its memory.

This brings an ArrayList to the same state as Init() and is equivalent to Resize(0) followed by Trim() . This is slower than just Resize(0) because subsequent use needs to allocate new memory.

See also:
Resize, Trim, Reserve

Definition at line 525 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Clear (  )  [inline]

Zeroes the size of an ArrayList and frees its memory.

This brings an ArrayList to the same state as Init() and is equivalent to Resize(0) followed by Trim() . This is slower than just Resize(0) because subsequent use needs to allocate new memory.

See also:
Resize, Trim, Reserve

Definition at line 525 of file arraylist.h.

Referenced by Dataset::GetLabels(), Dataset::n_labels(), RangeSet< TBoundary >::Reset(), and GeneralCrossValidator< TLearner >::Run().

template<typename TElem>
bool ArrayList< TElem >::empty (  )  const [inline]

Whether the ArrayList is empty (size 0).

Definition at line 1041 of file arraylist.h.

template<typename TElem>
bool ArrayList< TElem >::empty (  )  const [inline]

Whether the ArrayList is empty (size 0).

Definition at line 1041 of file arraylist.h.

template<typename TElem>
const Elem* ArrayList< TElem >::end (  )  const [inline]

Get a pointer to just past the end of the array.

Definition at line 1064 of file arraylist.h.

template<typename TElem>
const Elem* ArrayList< TElem >::end (  )  const [inline]

Get a pointer to just past the end of the array.

Definition at line 1064 of file arraylist.h.

Referenced by String::end(), and RangeSet< TBoundary >::Union().

template<typename TElem>
void ArrayList< TElem >::ExtractAppend ( index_t  pos,
index_t  size,
ArrayList< TElem > *  dest 
)

Moves multiple elements from a given position in an ArrayList to the end of another ArrayList.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an ArrayList to receive the elements
See also:
RemoveInit, ExtractInit, InfixCopy, SegmentAppend
template<typename TElem >
void ArrayList< TElem >::ExtractAppend ( index_t  pos,
index_t  size,
ArrayList< TElem > *  dest 
) [inline]

Moves multiple elements from a given position in an ArrayList to the end of another ArrayList.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an ArrayList to receive the elements
See also:
RemoveInit, ExtractInit, InfixCopy, SegmentAppend

Definition at line 1199 of file arraylist.h.

References ArrayList< TElem >::ExtractInit(), and ArrayList< TElem >::PushBackRaw().

template<typename TElem>
void ArrayList< TElem >::ExtractInit ( index_t  pos,
index_t  size,
ArrayList< TElem > *  dest 
)

Moves multiple elements from a given position in an ArrayList to a new ArrayList.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an uninitialized ArrayList to receive the elements
See also:
RemoveInit, ExtractAppend, InfixCopy, SegmentInit
template<typename TElem>
void ArrayList< TElem >::ExtractInit ( index_t  pos,
index_t  size,
Elem dest 
) [inline]

Moves multiple elements from a given position in an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest[i].~Elem() before this function, or just using the element in place followed by a normal Remove when finished.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an array of uninitialized objects to receive the elements
See also:
RemoveInit, InfixCopy, PopBackInit

Definition at line 993 of file arraylist.h.

template<typename TElem >
void ArrayList< TElem >::ExtractInit ( index_t  pos,
index_t  size,
ArrayList< TElem > *  dest 
) [inline]

Moves multiple elements from a given position in an ArrayList to a new ArrayList.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an uninitialized ArrayList to receive the elements
See also:
RemoveInit, ExtractAppend, InfixCopy, SegmentInit

Definition at line 1191 of file arraylist.h.

References ArrayList< TElem >::ExtractInit(), and ArrayList< TElem >::InitRaw().

template<typename TElem>
void ArrayList< TElem >::ExtractInit ( index_t  pos,
index_t  size,
Elem dest 
) [inline]

Moves multiple elements from a given position in an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest[i].~Elem() before this function, or just using the element in place followed by a normal Remove when finished.

Parameters:
pos the position of the first element to move
size the number of elements to move
dest an array of uninitialized objects to receive the elements
See also:
RemoveInit, InfixCopy, PopBackInit

Definition at line 993 of file arraylist.h.

Referenced by ArrayList< TElem >::ExtractAppend(), and ArrayList< TElem >::ExtractInit().

template<typename TElem>
const Elem& ArrayList< TElem >::front (  )  const [inline]

Get the first element in the array, as in *a.begin().

Definition at line 1072 of file arraylist.h.

template<typename TElem>
const Elem& ArrayList< TElem >::front (  )  const [inline]

Get the first element in the array, as in *a.begin().

Definition at line 1072 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::GrowTo ( index_t  size  )  [inline]

Increases an ArrayList's size, increasing capacity if needed, and default constructs newly added elements.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size the increased size; must be larger than starting size
See also:
ShrinkTo, Resize, Reserve

Definition at line 381 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::GrowTo ( index_t  size  )  [inline]

Increases an ArrayList's size, increasing capacity if needed, and default constructs newly added elements.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size the increased size; must be larger than starting size
See also:
ShrinkTo, Resize, Reserve

Definition at line 381 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::Resize(), and ArrayList< std::pair< index_t, index_t > >::SizeAtLeast().

template<typename TElem>
void ArrayList< TElem >::InfixCopy ( index_t  pos,
const ArrayList< TElem > &  src 
) [inline]

Adds copies of each element in a source ArrayList at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where infixed elements should appear
src the Arraylist to append
See also:
InsertCopy, InfixSteal, ExtractInit, AppendCopy

Definition at line 885 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InfixCopy ( index_t  pos,
const Elem src,
index_t  size 
) [inline]

Adds copies of each element in an array at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where infixed elements should appear
src the array of elements to infix
size the number of elements to infix
See also:
InsertCopy, ExtractInit, AppendCopy

Definition at line 866 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InfixCopy ( index_t  pos,
const ArrayList< TElem > &  src 
) [inline]

Adds copies of each element in a source ArrayList at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where infixed elements should appear
src the Arraylist to append
See also:
InsertCopy, InfixSteal, ExtractInit, AppendCopy

Definition at line 885 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InfixCopy ( index_t  pos,
const Elem src,
index_t  size 
) [inline]

Adds copies of each element in an array at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where infixed elements should appear
src the array of elements to infix
size the number of elements to infix
See also:
InsertCopy, ExtractInit, AppendCopy

Definition at line 866 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::InfixCopy().

template<typename TElem>
void ArrayList< TElem >::InfixSteal ( index_t  pos,
ArrayList< TElem > *  src 
)

Moves the elements in a source ArrayList to a given position in an ArrayList, converting the source into a sub-alias.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Given the above, be careful not to InfixSteal from multiple ArrayLists and then expect each of them to alias their respective portions of the created ArrayList, especially because infixed regions may ultimately (and inappropriately) overlap.

Parameters:
pos the position where infixed elements should appear
src the ArrayList to infix and steal from
See also:
AppendCopy, InfixSteal
template<typename TElem >
void ArrayList< TElem >::InfixSteal ( index_t  pos,
ArrayList< TElem > *  src 
) [inline]

Moves the elements in a source ArrayList to a given position in an ArrayList, converting the source into a sub-alias.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Given the above, be careful not to InfixSteal from multiple ArrayLists and then expect each of them to alias their respective portions of the created ArrayList, especially because infixed regions may ultimately (and inappropriately) overlap.

Parameters:
pos the position where infixed elements should appear
src the ArrayList to infix and steal from
See also:
AppendCopy, InfixSteal

Definition at line 1177 of file arraylist.h.

References ArrayList< TElem >::begin(), mem::Copy(), mem::Free(), ArrayList< TElem >::InsertRaw(), and ArrayList< TElem >::size().

template<typename TElem>
void ArrayList< TElem >::Init ( index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), default constructing the contents.

Parameters:
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
InitCopy, InitRepeat, InitRaw

Definition at line 183 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Init (  )  [inline]

Initializes an empty ArrayList.

See also:
InitCopy, InitRepeat, InitRaw, InitAlias, InitSteal

Definition at line 169 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Init ( index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), default constructing the contents.

Parameters:
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
InitCopy, InitRepeat, InitRaw

Definition at line 183 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Init (  )  [inline]
template<typename TElem>
void ArrayList< TElem >::InitAlias ( Elem ptr,
index_t  size 
) [inline]

Initializes an ArrayList as an alias of an array with a given size.

(Note that InitAlias of an ArrayList also exists.)

It is your responsibility to eventually free the aliased array, but said array must not be freed or moved for the duration of the alias's lifespan.

Parameters:
ptr the array to alias
size the length of the aliased array
See also:
Init, InitCopy, InitSubAlias

Definition at line 279 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitAlias ( Elem ptr,
index_t  size 
) [inline]

Initializes an ArrayList as an alias of an array with a given size.

(Note that InitAlias of an ArrayList also exists.)

It is your responsibility to eventually free the aliased array, but said array must not be freed or moved for the duration of the alias's lifespan.

Parameters:
ptr the array to alias
size the length of the aliased array
See also:
Init, InitCopy, InitSubAlias

Definition at line 279 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::InitSubAlias().

template<typename TElem>
void ArrayList< TElem >::InitCopy ( const ArrayList< TElem > &  src,
index_t  cap 
) [inline]

Initializes an ArrayList to a copy of another ArrayList, but with specified capacity.

Parameters:
src the initial values copied into the array
cap the initial amount of allocated space
See also:
Init, InitSubCopy

Definition at line 238 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitCopy ( const Elem src,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), element-wise copying the contents of another array.

(Note that InitCopy of an ArrayList also exists.)

Parameters:
ptr the initial values copied into the array
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
Init, InitRepeat, InitRaw, InitAlias, InitSteal

Definition at line 221 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitCopy ( const ArrayList< TElem > &  src,
index_t  cap 
) [inline]

Initializes an ArrayList to a copy of another ArrayList, but with specified capacity.

Parameters:
src the initial values copied into the array
cap the initial amount of allocated space
See also:
Init, InitSubCopy

Definition at line 238 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitCopy ( const Elem src,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), element-wise copying the contents of another array.

(Note that InitCopy of an ArrayList also exists.)

Parameters:
ptr the initial values copied into the array
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
Init, InitRepeat, InitRaw, InitAlias, InitSteal

Definition at line 221 of file arraylist.h.

Referenced by String::Copy(), MultSeriesExpansionAux::Init(), GaussianHMM::Init(), ArrayList< std::pair< index_t, index_t > >::InitCopy(), GaussianHMM::InitFromData(), GaussianHMM::InitFromFile(), ArrayList< std::pair< index_t, index_t > >::InitSubCopy(), GeneralCrossValidator< TLearner >::Run(), MixtureofGaussianHMM::setModel(), and GaussianHMM::setModel().

template<typename TElem>
Elem* ArrayList< TElem >::InitRaw ( index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size) but does not construct the contents.

This function can be used to initialize lists that will be constructed later (e.g. by copy construction) and is needed for the use of non-default constructors. It is important to construct or somehow fill the contents of the list before general use or destruction.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

Parameters:
size the initial number of elements
cap (optional) the initial amount of allocated space
Returns:
a pointer to the beginning of the array
See also:
Init, InitCopy, InitRepeat

Definition at line 153 of file arraylist.h.

template<typename TElem>
Elem* ArrayList< TElem >::InitRaw ( index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size) but does not construct the contents.

This function can be used to initialize lists that will be constructed later (e.g. by copy construction) and is needed for the use of non-default constructors. It is important to construct or somehow fill the contents of the list before general use or destruction.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

Parameters:
size the initial number of elements
cap (optional) the initial amount of allocated space
Returns:
a pointer to the beginning of the array
See also:
Init, InitCopy, InitRepeat

Definition at line 153 of file arraylist.h.

Referenced by ArrayList< TElem >::ExtractInit(), ArrayList< std::pair< index_t, index_t > >::Init(), ArrayList< std::pair< index_t, index_t > >::InitCopy(), ArrayList< std::pair< index_t, index_t > >::InitRepeat(), and ArrayList< TElem >::SegmentInit().

template<typename TElem>
void ArrayList< TElem >::InitRepeat ( const Elem elem,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), copying some object to each of the elements.

Parameters:
elem the initial value copied to each element
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
Init, InitCopy, InitRaw

Definition at line 202 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitRepeat ( const Elem elem,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList with a given size and (optionally) capacity (defaults to size), copying some object to each of the elements.

Parameters:
elem the initial value copied to each element
size the initial number of elements
cap (optional) the initial amount of allocated space
See also:
Init, InitCopy, InitRaw

Definition at line 202 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitSteal ( Elem ptr,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList directly with an array with a given size and (optionally) capacity (defaults to size).

(Note that InitSteal of an ArrayList also exists.)

The input array will be automatically freed when the ArrayList is destroyed and may be reallocated during use. Because ArrayLists use mem::Free and mem::Realloc, the array must be allocated with mem::Alloc (or more appropriately, mem::AllocConstruct) rather than new[].

Parameters:
ptr the array to steal (assume deallocation rights)
size the number of elements in the stolen array
cap (optional) the allocated size of the stolen array
See also:
Init, InitCopy, InitAlias

Definition at line 320 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitSteal ( Elem ptr,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList directly with an array with a given size and (optionally) capacity (defaults to size).

(Note that InitSteal of an ArrayList also exists.)

The input array will be automatically freed when the ArrayList is destroyed and may be reallocated during use. Because ArrayLists use mem::Free and mem::Realloc, the array must be allocated with mem::Alloc (or more appropriately, mem::AllocConstruct) rather than new[].

Parameters:
ptr the array to steal (assume deallocation rights)
size the number of elements in the stolen array
cap (optional) the allocated size of the stolen array
See also:
Init, InitCopy, InitAlias

Definition at line 320 of file arraylist.h.

Referenced by String::StealDestruct().

template<typename TElem>
void ArrayList< TElem >::InitSubAlias ( const ArrayList< TElem > &  src,
index_t  pos,
index_t  size 
) [inline]

Initializes an ArrayList as an alias of a section of another ArrayList.

Parameters:
src the ArrayList to copy from
pos the offset into the source list
size the number of elements to copy
See also:
Init, InitAlias, InitSubCopy

Definition at line 296 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitSubAlias ( const ArrayList< TElem > &  src,
index_t  pos,
index_t  size 
) [inline]

Initializes an ArrayList as an alias of a section of another ArrayList.

Parameters:
src the ArrayList to copy from
pos the offset into the source list
size the number of elements to copy
See also:
Init, InitAlias, InitSubCopy

Definition at line 296 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitSubCopy ( const ArrayList< TElem > &  src,
index_t  pos,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList to a copy of a section of another ArrayList, with (optionally) specified capacity (defaults to the other list's size).

Parameters:
src the ArrayList to copy from
pos the offset into the source list
size the number of elements to copy
cap (optional) the initial amount of allocated space
See also:
Init, InitCopy, InitSubAlias

Definition at line 255 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::InitSubCopy ( const ArrayList< TElem > &  src,
index_t  pos,
index_t  size,
index_t  cap 
) [inline]

Initializes an ArrayList to a copy of a section of another ArrayList, with (optionally) specified capacity (defaults to the other list's size).

Parameters:
src the ArrayList to copy from
pos the offset into the source list
size the number of elements to copy
cap (optional) the initial amount of allocated space
See also:
Init, InitCopy, InitSubAlias

Definition at line 255 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Insert ( index_t  pos,
index_t  inc 
) [inline]

Adds (optionally) inc elements (default 1) at a given position in an ArrayList, default constructing them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where new elements should appear
inc (optional) the number of elements to add
See also:
InsertCopy, InfixCopy, InsertRaw, Remove, PushBack

Definition at line 822 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Insert ( index_t  pos,
index_t  inc 
) [inline]

Adds (optionally) inc elements (default 1) at a given position in an ArrayList, default constructing them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where new elements should appear
inc (optional) the number of elements to add
See also:
InsertCopy, InfixCopy, InsertRaw, Remove, PushBack

Definition at line 822 of file arraylist.h.

template<typename TElem>
Elem& ArrayList< TElem >::InsertCopy ( index_t  pos,
const Elem src 
) [inline]

Adds a copy of an element at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where the new element should appear
src the element to add
See also:
Insert, InfixCopy, RemoveInit, PushBackCopy

Definition at line 845 of file arraylist.h.

template<typename TElem>
Elem& ArrayList< TElem >::InsertCopy ( index_t  pos,
const Elem src 
) [inline]

Adds a copy of an element at a given position in an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where the new element should appear
src the element to add
See also:
Insert, InfixCopy, RemoveInit, PushBackCopy

Definition at line 845 of file arraylist.h.

template<typename TElem>
Elem* ArrayList< TElem >::InsertRaw ( index_t  pos,
index_t  inc = 1 
) [inline]

Adds (optionally) inc elements (default 1) at a given position in an ArrayList, but does not construct them.

It is important for you to construct or otherwise fill added elements before you use them.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where new elements should appear
inc (optional) the number of elements to add
Returns:
a pointer to the first of the added elements
See also:
Insert, InsertCopy, InfixCopy, RemoveRaw, PushBackRaw

Definition at line 796 of file arraylist.h.

template<typename TElem>
Elem* ArrayList< TElem >::InsertRaw ( index_t  pos,
index_t  inc = 1 
) [inline]

Adds (optionally) inc elements (default 1) at a given position in an ArrayList, but does not construct them.

It is important for you to construct or otherwise fill added elements before you use them.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
pos the position where new elements should appear
inc (optional) the number of elements to add
Returns:
a pointer to the first of the added elements
See also:
Insert, InsertCopy, InfixCopy, RemoveRaw, PushBackRaw

Definition at line 796 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::InfixCopy(), ArrayList< TElem >::InfixSteal(), ArrayList< std::pair< index_t, index_t > >::Insert(), and ArrayList< std::pair< index_t, index_t > >::InsertCopy().

template<typename TElem>
index_t ArrayList< TElem >::length (  )  const [inline]

The number of active elements in the ArrayList.

This function is defined so that it provides the same interface for lapack/blas operations

Definition at line 1032 of file arraylist.h.

template<typename TElem>
index_t ArrayList< TElem >::length (  )  const [inline]

The number of active elements in the ArrayList.

This function is defined so that it provides the same interface for lapack/blas operations

Definition at line 1032 of file arraylist.h.

Referenced by DiscreteHMM::ComputeLogLikelihood(), AllNN::EmitResults(), GaussianHMM::GenerateInit(), DiscreteHMM::InitFromData(), DiscreteHMM::Train(), and DiscreteHMM::TrainViterbi().

template<typename TElem>
const Elem& ArrayList< TElem >::operator[] ( index_t  i  )  const [inline]

Access an element at position i.

Definition at line 1046 of file arraylist.h.

template<typename TElem>
const Elem& ArrayList< TElem >::operator[] ( index_t  i  )  const [inline]

Access an element at position i.

Definition at line 1046 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PopBack ( index_t  dec = 1  )  [inline]

Removes (optionally) dec elements (default 1) from the end of an ArrayList, destructing them.

Equivalent to a.ShrinkTo(a.size() - dec)

Parameters:
dec (optional) the number of elements to remove
See also:
PopBackInit, SegmentInit, PopBackRaw, PushBack, Remove, ShrinkTo

Definition at line 699 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PopBack ( index_t  dec = 1  )  [inline]

Removes (optionally) dec elements (default 1) from the end of an ArrayList, destructing them.

Equivalent to a.ShrinkTo(a.size() - dec)

Parameters:
dec (optional) the number of elements to remove
See also:
PopBackInit, SegmentInit, PopBackRaw, PushBack, Remove, ShrinkTo

Definition at line 699 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PopBackInit ( Elem dest  )  [inline]

Moves an element from the end of an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest->~Elem() before this function, or just using the element in place followed by a normal PopBack when finished.

Parameters:
dest an uninitialized object to receive the element
See also:
PopBack, SegmentInit, PushBackCopy, RemoveInit

Definition at line 719 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PopBackInit ( Elem dest  )  [inline]

Moves an element from the end of an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest->~Elem() before this function, or just using the element in place followed by a normal PopBack when finished.

Parameters:
dest an uninitialized object to receive the element
See also:
PopBack, SegmentInit, PushBackCopy, RemoveInit

Definition at line 719 of file arraylist.h.

Referenced by MinHeap< double, Grain * >::PopOnly().

template<typename TElem>
void ArrayList< TElem >::PopBackRaw ( index_t  dec = 1  )  [inline]

Removes (optionally) dec elements (default 1) from the end of an ArrayList, but does not destruct them.

While it is technically possible to call this function and destruct elements afterwards, it is recommended for you to destruct elements first to minimize code change if you have to move to RemoveRaw.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP destruction and thus no performance gains come of using this function with them.

Parameters:
dec (optional) the number of elements to remove
See also:
PopBack, PopBackInit, SegmentInit, PushBackRaw, RemoveRaw

Definition at line 683 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PopBackRaw ( index_t  dec = 1  )  [inline]

Removes (optionally) dec elements (default 1) from the end of an ArrayList, but does not destruct them.

While it is technically possible to call this function and destruct elements afterwards, it is recommended for you to destruct elements first to minimize code change if you have to move to RemoveRaw.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP destruction and thus no performance gains come of using this function with them.

Parameters:
dec (optional) the number of elements to remove
See also:
PopBack, PopBackInit, SegmentInit, PushBackRaw, RemoveRaw

Definition at line 683 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::PopBack(), ArrayList< std::pair< index_t, index_t > >::PopBackInit(), and ArrayList< std::pair< index_t, index_t > >::SegmentInit().

template<typename TElem>
void ArrayList< TElem >::PushBack ( index_t  inc  )  [inline]

Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them.

Equivalent to a.GrowTo(a.size() + inc)

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
inc (optional) the number of elements to add
See also:
PushBackCopy, AppendCopy, PushBackRaw, PopBack, Insert, GrowTo

Definition at line 582 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::PushBack ( index_t  inc  )  [inline]

Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them.

Equivalent to a.GrowTo(a.size() + inc)

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
inc (optional) the number of elements to add
See also:
PushBackCopy, AppendCopy, PushBackRaw, PopBack, Insert, GrowTo

Definition at line 582 of file arraylist.h.

Referenced by Dataset::GetLabels(), DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), Dataset::n_labels(), MinHeap< double, Grain * >::Put(), and String::Split().

template<typename TElem>
Elem& ArrayList< TElem >::PushBackCopy ( const Elem src  )  [inline]

Adds a copy of an element to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the element to add
See also:
PushBack, AppendCopy, PopBackInit, InsertCopy

Definition at line 603 of file arraylist.h.

template<typename TElem>
Elem& ArrayList< TElem >::PushBackCopy ( const Elem src  )  [inline]

Adds a copy of an element to the end of an ArrayList.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
src the element to add
See also:
PushBack, AppendCopy, PopBackInit, InsertCopy

Definition at line 603 of file arraylist.h.

Referenced by String::Append(), MixtureofGaussianHMM::ComputeLogLikelihood(), GaussianHMM::ComputeLogLikelihood(), DiscreteHMM::ComputeLogLikelihood(), GaussianHMM::InitGaussParameter(), MixtureofGaussianHMM::Train(), and RangeSet< TBoundary >::Union().

template<typename TElem>
Elem* ArrayList< TElem >::PushBackRaw ( index_t  inc = 1  )  [inline]

Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them.

It is important for you to construct or otherwise fill added elements before you use them.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
inc (optional) the number of elements to add
Returns:
a pointer to the first of the added elements
See also:
PushBack, PushBackCopy, AppendCopy, PopBackRaw, InsertRaw

Definition at line 554 of file arraylist.h.

template<typename TElem>
Elem* ArrayList< TElem >::PushBackRaw ( index_t  inc = 1  )  [inline]

Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them.

It is important for you to construct or otherwise fill added elements before you use them.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP construction and thus no performance gains come of using this function with them.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
inc (optional) the number of elements to add
Returns:
a pointer to the first of the added elements
See also:
PushBack, PushBackCopy, AppendCopy, PopBackRaw, InsertRaw

Definition at line 554 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::AppendCopy(), ArrayList< TElem >::AppendSteal(), ArrayList< TElem >::ExtractAppend(), ArrayList< std::pair< index_t, index_t > >::PushBack(), ArrayList< std::pair< index_t, index_t > >::PushBackCopy(), DatasetInfo::ReadMatrix(), ArrayList< TElem >::SegmentAppend(), and RangeSet< TBoundary >::Union().

template<typename TElem>
Elem* ArrayList< TElem >::ReleasePtr (  )  [inline]

Returns a pointer to the beginning of the ArrayList's array and demotes the ArrayList to an alias (voids deallocation rights).

It is your responsibility to eventually free the returned array, but said array must not be freed or moved for the duration of the (now aliasing) ArrayList's lifespan. Because ArrayLists use mem::Alloc, the array must be deallocated with mem::Free.

See also:
InitSteal

Definition at line 343 of file arraylist.h.

template<typename TElem>
Elem* ArrayList< TElem >::ReleasePtr (  )  [inline]

Returns a pointer to the beginning of the ArrayList's array and demotes the ArrayList to an alias (voids deallocation rights).

It is your responsibility to eventually free the returned array, but said array must not be freed or moved for the duration of the (now aliasing) ArrayList's lifespan. Because ArrayLists use mem::Alloc, the array must be deallocated with mem::Free.

See also:
InitSteal

Definition at line 343 of file arraylist.h.

Referenced by DatasetInfo::ReadMatrix().

template<typename TElem>
void ArrayList< TElem >::Remove ( index_t  pos,
index_t  dec = 1 
) [inline]

Removes (optionally) dec elements (default 1) from a given position in an ArrayList, destructing them.

Parameters:
pos the position of the first element to remove
dec (optional) the number of elements to remove
See also:
RemoveInit, ExtractInit, RemoveRaw, Insert, PopBack

Definition at line 945 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Remove ( index_t  pos,
index_t  dec = 1 
) [inline]

Removes (optionally) dec elements (default 1) from a given position in an ArrayList, destructing them.

Parameters:
pos the position of the first element to remove
dec (optional) the number of elements to remove
See also:
RemoveInit, ExtractInit, RemoveRaw, Insert, PopBack

Definition at line 945 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::RemoveInit ( index_t  pos,
Elem dest 
) [inline]

Moves an element from a given position in an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest->~Elem() before this function, or just using the element in place followed by a normal Remove when finished.

Parameters:
pos the position of the element to move
dest an uninitialized object to receive the element
See also:
Remove, ExtractInit, InsertCopy, PopBackInit

Definition at line 967 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::RemoveInit ( index_t  pos,
Elem dest 
) [inline]

Moves an element from a given position in an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest->~Elem() before this function, or just using the element in place followed by a normal Remove when finished.

Parameters:
pos the position of the element to move
dest an uninitialized object to receive the element
See also:
Remove, ExtractInit, InsertCopy, PopBackInit

Definition at line 967 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::RemoveRaw ( index_t  pos,
index_t  dec = 1 
) [inline]

Removes (optionally) dec elements (default 1) from a given position in an ArrayList, but does not destruct them.

It is important for you to destruct elements before calling this function, as they will be overwritten.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP destruction and thus no performance gains come of using this function with them.

Parameters:
pos the position of the first element to remove
dec (optional) the number of elements to remove
See also:
Remove, RemoveInit, ExtractInit, InsertRaw, PopBackRaw

Definition at line 930 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::RemoveRaw ( index_t  pos,
index_t  dec = 1 
) [inline]

Removes (optionally) dec elements (default 1) from a given position in an ArrayList, but does not destruct them.

It is important for you to destruct elements before calling this function, as they will be overwritten.

Note that shallow types (ints, doubles, etc. and types declared with OBJECT_TRAVERSAL_SHALLOW) have NOP destruction and thus no performance gains come of using this function with them.

Parameters:
pos the position of the first element to remove
dec (optional) the number of elements to remove
See also:
Remove, RemoveInit, ExtractInit, InsertRaw, PopBackRaw

Definition at line 930 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::ExtractInit(), ArrayList< std::pair< index_t, index_t > >::Remove(), and ArrayList< std::pair< index_t, index_t > >::RemoveInit().

template<typename TElem>
void ArrayList< TElem >::Reserve ( index_t  size  )  [inline]

Ensures that an ArrayList has capacity greater than a given size.

Note that all operations that add elements to ArrayLists will automatically increase capacity as needed. This command's purpose it to reduce the frequency of such operations in hand-tuned situations or to ensure that pointers remain valid after subsequent resizings (though this practice is error prone and thus not recommended).

This operation invalidates all pointers into the ArrayList (including aliases).

Parameters:
size the needed minimum capacity of the array
See also:
Trim, Resize, Clear

Definition at line 487 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Reserve ( index_t  size  )  [inline]

Ensures that an ArrayList has capacity greater than a given size.

Note that all operations that add elements to ArrayLists will automatically increase capacity as needed. This command's purpose it to reduce the frequency of such operations in hand-tuned situations or to ensure that pointers remain valid after subsequent resizings (though this practice is error prone and thus not recommended).

This operation invalidates all pointers into the ArrayList (including aliases).

Parameters:
size the needed minimum capacity of the array
See also:
Trim, Resize, Clear

Definition at line 487 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Resize ( index_t  size  )  [inline]

Changes an ArrayList's size, increasing capacity if needed, and constructing or destructing elements as appropriate.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size the new size for the array
See also:
GrowTo, ShrinkTo, Reserve, Trim, Clear

Definition at line 423 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Resize ( index_t  size  )  [inline]

Changes an ArrayList's size, increasing capacity if needed, and constructing or destructing elements as appropriate.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size the new size for the array
See also:
GrowTo, ShrinkTo, Reserve, Trim, Clear

Definition at line 423 of file arraylist.h.

Referenced by String::Append(), String::FixLength(), SimpleNaiveBayesClassifier::InitTrain(), DatasetInfo::ReadMatrix(), String::SetLength(), and String::Truncate().

template<typename TElem>
void ArrayList< TElem >::SegmentAppend ( index_t  size,
ArrayList< TElem > *  dest 
)

Moves multiple elements from the end of an ArrayList to the end of another ArrayList.

Parameters:
size the number of elements to move
dest an ArrayList to receive the elements
See also:
PopBackInit, SegmentInit, AppendCopy, ExtractAppend
template<typename TElem >
void ArrayList< TElem >::SegmentAppend ( index_t  size,
ArrayList< TElem > *  dest 
) [inline]

Moves multiple elements from the end of an ArrayList to the end of another ArrayList.

Parameters:
size the number of elements to move
dest an ArrayList to receive the elements
See also:
PopBackInit, SegmentInit, AppendCopy, ExtractAppend

Definition at line 1170 of file arraylist.h.

References ArrayList< TElem >::PushBackRaw(), and ArrayList< TElem >::SegmentInit().

template<typename TElem>
void ArrayList< TElem >::SegmentInit ( index_t  size,
ArrayList< TElem > *  dest 
)

Moves multiple elements from the end of an ArrayList to a new ArrayList.

Parameters:
size the number of elements to move
dest an uninitialized ArrayList to receive the elements
See also:
PopBackInit, SegmentAppend, AppendCopy, ExtractInit
template<typename TElem>
void ArrayList< TElem >::SegmentInit ( index_t  size,
Elem dest 
) [inline]

Moves multiple elements from the end of an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest[i].~Elem() before this function, or just using the element in place followed by a normal PopBack when finished.

Parameters:
size the number of elements to move
dest an array of uninitialized objects to receive the elements
See also:
PopBackInit, AppendCopy, RemoveInit

Definition at line 744 of file arraylist.h.

template<typename TElem >
void ArrayList< TElem >::SegmentInit ( index_t  size,
ArrayList< TElem > *  dest 
) [inline]

Moves multiple elements from the end of an ArrayList to a new ArrayList.

Parameters:
size the number of elements to move
dest an uninitialized ArrayList to receive the elements
See also:
PopBackInit, SegmentAppend, AppendCopy, ExtractInit

Definition at line 1163 of file arraylist.h.

References ArrayList< TElem >::InitRaw(), and ArrayList< TElem >::SegmentInit().

template<typename TElem>
void ArrayList< TElem >::SegmentInit ( index_t  size,
Elem dest 
) [inline]

Moves multiple elements from the end of an ArrayList to a given location.

Provided dest must have no clean-up responsibilities. This is always true of shallow types and generally true of travsered types that have not been initialized, but can be complicated for untraversed types that allocate on construction. Consider calling dest[i].~Elem() before this function, or just using the element in place followed by a normal PopBack when finished.

Parameters:
size the number of elements to move
dest an array of uninitialized objects to receive the elements
See also:
PopBackInit, AppendCopy, RemoveInit

Definition at line 744 of file arraylist.h.

Referenced by ArrayList< TElem >::SegmentAppend(), and ArrayList< TElem >::SegmentInit().

template<typename TElem>
void ArrayList< TElem >::ShrinkTo ( index_t  size  )  [inline]

Decreases an ArrayList's size, destructing removed elements.

This operation does not strictly invalidate pointers into the ArrayList because it never reallocates to take less space, but pointers to beyond the new size of the array are invalid because they reference destructed objects.

Parameters:
size the decreased size; must be less than starting size
See also:
GrowTo, Resize, Reserve

Definition at line 403 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::ShrinkTo ( index_t  size  )  [inline]

Decreases an ArrayList's size, destructing removed elements.

This operation does not strictly invalidate pointers into the ArrayList because it never reallocates to take less space, but pointers to beyond the new size of the array are invalid because they reference destructed objects.

Parameters:
size the decreased size; must be less than starting size
See also:
GrowTo, Resize, Reserve

Definition at line 403 of file arraylist.h.

Referenced by ArrayList< std::pair< index_t, index_t > >::Resize(), and ArrayList< std::pair< index_t, index_t > >::SizeAtMost().

template<typename TElem>
index_t ArrayList< TElem >::size (  )  const [inline]

The number of active elements in the ArrayList.

Definition at line 1026 of file arraylist.h.

template<typename TElem>
index_t ArrayList< TElem >::size (  )  const [inline]

The number of active elements in the ArrayList.

Definition at line 1026 of file arraylist.h.

Referenced by String::Append(), ArrayList< std::pair< index_t, index_t > >::AppendCopy(), ArrayList< TElem >::AppendSteal(), MixtureofGaussianHMM::ComputeLogLikelihood(), GaussianHMM::ComputeLogLikelihood(), DiscreteHMM::ComputeLogLikelihood(), SeriesExpansionAux::ComputeMultiindexPosition(), AllkNN::ComputeNaive(), AllkFN::ComputeNaive(), AllkNN::ComputeNeighbors(), AllkFN::ComputeNeighbors(), AllNN::EmitResults(), MixtureofGaussianHMM::GenerateInit(), GaussianHMM::GenerateInit(), ArrayList< std::pair< index_t, index_t > >::InfixCopy(), ArrayList< TElem >::InfixSteal(), NaiveKde< TKernel >::Init(), GaussianHMM::Init(), ArrayList< std::pair< index_t, index_t > >::InitCopy(), DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), GaussianHMM::InitFromData(), DiscreteHMM::InitFromData(), GaussianHMM::InitFromFile(), DiscreteHMM::InitFromFile(), GaussianHMM::InitGaussParameter(), ArrayList< std::pair< index_t, index_t > >::InitSubAlias(), ArrayList< std::pair< index_t, index_t > >::InitSubCopy(), DatasetInfo::is_all_continuous(), MinHeap< double, Grain * >::is_empty(), String::is_empty(), data::LargeLoad(), String::length(), ArrayList< std::pair< index_t, index_t > >::length(), math::MakeInversePermutation(), DatasetInfo::n_features(), DatasetFeature::n_values(), DatasetFeature::Parse(), MinHeap< double, Grain * >::PopOnly(), SeriesExpansionAux::PrintDebug(), MultSeriesExpansionAux::PrintDebug(), MinHeap< double, Grain * >::Put(), DatasetInfo::ReadMatrix(), GeneralCrossValidator< TLearner >::Run(), MixtureofGaussianHMM::setModel(), GaussianHMM::setModel(), RangeSet< TBoundary >::size(), MinHeap< double, Grain * >::size(), MixtureofGaussianHMM::Train(), DiscreteHMM::Train(), DiscreteHMM::TrainViterbi(), RangeSet< TBoundary >::Union(), DatasetInfo::WriteArffHeader(), DatasetInfo::WriteCsvHeader(), and DatasetInfo::WriteMatrix().

template<typename TElem>
void ArrayList< TElem >::SizeAtLeast ( index_t  size  )  [inline]

Ensures that an ArrayList has at least size active elements, adding and constructing elements as appropriate.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size a lower bound on the size for the array
See also:
Resize, GrowTo, Reserve

Definition at line 446 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::SizeAtLeast ( index_t  size  )  [inline]

Ensures that an ArrayList has at least size active elements, adding and constructing elements as appropriate.

This operation invalidates all pointers into the ArrayList (including aliases) unless you can prove that the new size does not exceed capacity, i.e. you Reserved space before creating the pointers/aliases.

Parameters:
size a lower bound on the size for the array
See also:
Resize, GrowTo, Reserve

Definition at line 446 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::SizeAtMost ( index_t  size  )  [inline]

Ensures that an ArrayList has at most size active elements, destructing and removing elements as appropriate.

Parameters:
size an upper bound on the size for the array
See also:
Resize, ShrinkTo, Trim

Definition at line 462 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::SizeAtMost ( index_t  size  )  [inline]

Ensures that an ArrayList has at most size active elements, destructing and removing elements as appropriate.

Parameters:
size an upper bound on the size for the array
See also:
Resize, ShrinkTo, Trim

Definition at line 462 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Swap ( ArrayList< TElem > *  other  )  [inline]

Exchanges arrays with another ArrayList.

You can swap aliases and non-aliases safely. Aliases made to swapped arrays are not invalidated, but still point to the same elements, i.e. which ArrayLists they alias are also conceptually swapped.

Parameters:
other the ArrayList to exchange with
See also:
InitCopy, InitAlias, InitSteal

Definition at line 361 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Swap ( ArrayList< TElem > *  other  )  [inline]

Exchanges arrays with another ArrayList.

You can swap aliases and non-aliases safely. Aliases made to swapped arrays are not invalidated, but still point to the same elements, i.e. which ArrayLists they alias are also conceptually swapped.

Parameters:
other the ArrayList to exchange with
See also:
InitCopy, InitAlias, InitSteal

Definition at line 361 of file arraylist.h.

Referenced by String::Swap(), ArrayList< std::pair< index_t, index_t > >::Swap(), and RangeSet< TBoundary >::Union().

template<typename TElem>
void ArrayList< TElem >::Trim (  )  [inline]

Reduces the capacity of an ArrayList to exactly its size.

This may be useful to conserve memory in certain situations, but keep in mind that copying, freezing, and serializing ArrayLists already only uses as much space as is necessary to represent the active objects.

This operation invalidates all pointers into the ArrayList (including aliases).

See also:
Reserve, Resize, Clear

Definition at line 509 of file arraylist.h.

template<typename TElem>
void ArrayList< TElem >::Trim (  )  [inline]

Reduces the capacity of an ArrayList to exactly its size.

This may be useful to conserve memory in certain situations, but keep in mind that copying, freezing, and serializing ArrayLists already only uses as much space as is necessary to represent the active objects.

This operation invalidates all pointers into the ArrayList (including aliases).

See also:
Reserve, Resize, Clear

Definition at line 509 of file arraylist.h.

Referenced by DatasetInfo::ReadMatrix(), and String::Trim().


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 12:04:40 2011 for FASTlib by  doxygen 1.6.3