A typical multi-purpose, resizable array, coded with an emphasis on speed. More...
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 | |
Elem * | AddBack (index_t inc=1) |
Elem * | AddBack (index_t inc=1) |
Elem * | AddBackItem (const Elem &elem) |
Elem * | AddBackItem (const Elem &elem) |
Elem * | AddBackUnconstructed (index_t inc=1) |
Elem * | AddBackUnconstructed (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. | |
Elem & | back () |
const Elem & | back () const |
Get the last element in the array, as in * (a.end() - 1). | |
Elem & | back () |
const Elem & | back () const |
Get the last element in the array, as in * (a.end() - 1). | |
Elem * | begin () |
const Elem * | begin () const |
Get a pointer to the beginning of the array. | |
Elem * | begin () |
const Elem * | begin () 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). | |
Elem * | end () |
const Elem * | end () const |
Get a pointer to just past the end of the array. | |
Elem * | end () |
const Elem * | end () 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. | |
Elem & | front () |
const Elem & | front () const |
Get the first element in the array, as in *a .begin(). | |
Elem & | front () |
const Elem & | front () 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. | |
Elem * | InitRaw (index_t size) |
Elem * | InitRaw (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. | |
Elem * | InitRaw (index_t size) |
Elem * | InitRaw (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). | |
Elem & | Insert (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. | |
Elem & | Insert (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. | |
Elem & | InsertCopy (index_t pos, const Elem &src) |
Adds a copy of an element at a given position in an ArrayList. | |
Elem & | InsertCopy (index_t pos, const Elem &src) |
Adds a copy of an element at a given position in an ArrayList. | |
Elem * | InsertRaw (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. | |
Elem * | InsertRaw (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. | |
Elem & | operator[] (index_t i) |
const Elem & | operator[] (index_t i) const |
Access an element at position i. | |
Elem & | operator[] (index_t i) |
const Elem & | operator[] (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. | |
Elem * | PopBackPtr () |
Elem * | PopBackPtr () |
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. | |
Elem & | PushBack () |
void | PushBack (index_t inc) |
Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them. | |
Elem & | PushBack () |
void | PushBack (index_t inc) |
Adds (optionally) inc elements (default 1) to the end of an ArrayList, default constructing them. | |
Elem & | PushBackCopy (const Elem &src) |
Adds a copy of an element to the end of an ArrayList. | |
Elem & | PushBackCopy (const Elem &src) |
Adds a copy of an element to the end of an ArrayList. | |
Elem * | PushBackRaw (index_t inc=1) |
Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them. | |
Elem * | PushBackRaw (index_t inc=1) |
Adds (optionally) inc elements (default 1) to the end of an ArrayList, but does not construct them. | |
Elem * | ReleasePointer () |
Elem * | ReleasePointer () |
Elem * | ReleasePtr () |
Returns a pointer to the beginning of the ArrayList's array and demotes the ArrayList to an alias (voids deallocation rights). | |
Elem * | ReleasePtr () |
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. |
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.
An accessible typedef for the elements in the array.
Definition at line 87 of file arraylist.h.
An accessible typedef for the elements in the array.
Definition at line 87 of file arraylist.h.
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.
src | the Arraylist to append |
Definition at line 640 of file arraylist.h.
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.
src | the array of elements to append | |
size | the number of elements to append |
Definition at line 622 of file arraylist.h.
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.
src | the Arraylist to append |
Definition at line 640 of file arraylist.h.
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.
src | the array of elements to append | |
size | the number of elements to append |
Definition at line 622 of file arraylist.h.
Referenced by ArrayList< std::pair< index_t, index_t > >::AppendCopy().
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.
src | the ArrayList to append and steal from |
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.
src | the ArrayList to append and steal from |
Definition at line 1150 of file arraylist.h.
References ArrayList< TElem >::begin(), mem::Copy(), mem::Free(), ArrayList< TElem >::PushBackRaw(), and ArrayList< TElem >::size().
Get the last element in the array, as in *
(a.end() - 1).
Definition at line 1080 of file arraylist.h.
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().
Get a pointer to the beginning of the array.
Definition at line 1056 of file arraylist.h.
Get a pointer to the beginning of the array.
Definition at line 1056 of file arraylist.h.
Referenced by String::Append(), ArrayList< std::pair< index_t, index_t > >::AppendCopy(), ArrayList< TElem >::AppendSteal(), String::begin(), String::c_str(), String::CompareNoCase(), FFTKde::Compute(), String::Copy(), String::FixLength(), ArrayList< std::pair< index_t, index_t > >::InfixCopy(), ArrayList< TElem >::InfixSteal(), ArrayList< std::pair< index_t, index_t > >::InitCopy(), ArrayList< std::pair< index_t, index_t > >::InitSubAlias(), ArrayList< std::pair< index_t, index_t > >::InitSubCopy(), math::MakeIdentityPermutation(), math::MakeInversePermutation(), math::MakeRandomPermutation(), String::operator const char *(), String::StartsWith(), and RangeSet< TBoundary >::Union().
index_t ArrayList< TElem >::capacity | ( | ) | const [inline] |
The allocated number of elements, or -1 if alias.
Definition at line 1037 of file arraylist.h.
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().
void ArrayList< TElem >::Clear | ( | ) | [inline] |
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.
Definition at line 525 of file arraylist.h.
Referenced by Dataset::GetLabels(), Dataset::n_labels(), RangeSet< TBoundary >::Reset(), and GeneralCrossValidator< TLearner >::Run().
bool ArrayList< TElem >::empty | ( | ) | const [inline] |
Whether the ArrayList is empty (size 0).
Definition at line 1041 of file arraylist.h.
bool ArrayList< TElem >::empty | ( | ) | const [inline] |
Whether the ArrayList is empty (size 0).
Definition at line 1041 of file arraylist.h.
Get a pointer to just past the end of the array.
Definition at line 1064 of file arraylist.h.
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().
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.
pos | the position of the first element to move | |
size | the number of elements to move | |
dest | an ArrayList to receive the elements |
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.
pos | the position of the first element to move | |
size | the number of elements to move | |
dest | an ArrayList to receive the elements |
Definition at line 1199 of file arraylist.h.
References ArrayList< TElem >::ExtractInit(), and ArrayList< TElem >::PushBackRaw().
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.
pos | the position of the first element to move | |
size | the number of elements to move | |
dest | an uninitialized ArrayList to receive the elements |
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.
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 |
Definition at line 993 of file arraylist.h.
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.
pos | the position of the first element to move | |
size | the number of elements to move | |
dest | an uninitialized ArrayList to receive the elements |
Definition at line 1191 of file arraylist.h.
References ArrayList< TElem >::ExtractInit(), and ArrayList< TElem >::InitRaw().
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.
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 |
Definition at line 993 of file arraylist.h.
Referenced by ArrayList< TElem >::ExtractAppend(), and ArrayList< TElem >::ExtractInit().
Get the first element in the array, as in *a
.begin().
Definition at line 1072 of file arraylist.h.
Get the first element in the array, as in *a
.begin().
Definition at line 1072 of file arraylist.h.
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.
size | the increased size; must be larger than starting size |
Definition at line 381 of file arraylist.h.
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.
size | the increased size; must be larger than starting size |
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().
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.
pos | the position where infixed elements should appear | |
src | the Arraylist to append |
Definition at line 885 of file arraylist.h.
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.
pos | the position where infixed elements should appear | |
src | the array of elements to infix | |
size | the number of elements to infix |
Definition at line 866 of file arraylist.h.
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.
pos | the position where infixed elements should appear | |
src | the Arraylist to append |
Definition at line 885 of file arraylist.h.
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.
pos | the position where infixed elements should appear | |
src | the array of elements to infix | |
size | the number of elements to infix |
Definition at line 866 of file arraylist.h.
Referenced by ArrayList< std::pair< index_t, index_t > >::InfixCopy().
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.
pos | the position where infixed elements should appear | |
src | the ArrayList to infix and steal from |
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.
pos | the position where infixed elements should appear | |
src | the ArrayList to infix and steal from |
Definition at line 1177 of file arraylist.h.
References ArrayList< TElem >::begin(), mem::Copy(), mem::Free(), ArrayList< TElem >::InsertRaw(), and ArrayList< TElem >::size().
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.
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 183 of file arraylist.h.
void ArrayList< TElem >::Init | ( | ) | [inline] |
Initializes an empty ArrayList.
Definition at line 169 of file arraylist.h.
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.
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 183 of file arraylist.h.
void ArrayList< TElem >::Init | ( | ) | [inline] |
Initializes an empty ArrayList.
Definition at line 169 of file arraylist.h.
Referenced by MixtureofGaussianHMM::ComputeLogLikelihood(), GaussianHMM::ComputeLogLikelihood(), DiscreteHMM::ComputeLogLikelihood(), AllkNN::ComputeNaive(), AllkFN::ComputeNaive(), AllkNN::ComputeNeighbors(), AllkFN::ComputeNeighbors(), String::Copy(), AllNN::EmitResults(), MoGEM::ExpectationMaximization(), Dataset::GetLabels(), MoGL2E::GoodnessOfFitTerm_(), SVM< TKernel >::Init(), SeriesExpansionAux::Init(), MultSeriesExpansionAux::Init(), NaiveKde< TKernel >::Init(), FFTKde::Init(), MixtureofGaussianHMM::Init(), AllkNN::Init(), AllkFN::Init(), DatasetInfo::Init(), RangeSet< TBoundary >::Init(), MinHeap< double, Grain * >::Init(), String::Init(), AllNN::Init(), DatasetInfo::InitContinuous(), DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), GaussianHMM::InitGaussParameter(), MoGL2E::InitialPointGenerator(), AllkFN::InitNaive(), AllNN::InitNaive(), SimpleNaiveBayesClassifier::InitTrain(), MoGEM::KMeans(), MoGL2E::KMeans_(), data::LargeLoad(), math::MakeIdentityPermutation(), math::MakeInversePermutation(), math::MakeRandomPermutation(), Dataset::n_labels(), DatasetInfo::ReadMatrix(), MoGL2E::RegularizationTerm_(), GeneralCrossValidator< TLearner >::Run(), MixtureofGaussianHMM::Train(), and RangeSet< TBoundary >::Union().
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.
ptr | the array to alias | |
size | the length of the aliased array |
Definition at line 279 of file arraylist.h.
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.
ptr | the array to alias | |
size | the length of the aliased array |
Definition at line 279 of file arraylist.h.
Referenced by ArrayList< std::pair< index_t, index_t > >::InitSubAlias().
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.
src | the initial values copied into the array | |
cap | the initial amount of allocated space |
Definition at line 238 of file arraylist.h.
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.)
ptr | the initial values copied into the array | |
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 221 of file arraylist.h.
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.
src | the initial values copied into the array | |
cap | the initial amount of allocated space |
Definition at line 238 of file arraylist.h.
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.)
ptr | the initial values copied into the array | |
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
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().
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.
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 153 of file arraylist.h.
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.
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
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().
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.
elem | the initial value copied to each element | |
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 202 of file arraylist.h.
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.
elem | the initial value copied to each element | |
size | the initial number of elements | |
cap | (optional) the initial amount of allocated space |
Definition at line 202 of file arraylist.h.
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[].
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 |
Definition at line 320 of file arraylist.h.
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[].
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 |
Definition at line 320 of file arraylist.h.
Referenced by String::StealDestruct().
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.
src | the ArrayList to copy from | |
pos | the offset into the source list | |
size | the number of elements to copy |
Definition at line 296 of file arraylist.h.
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.
src | the ArrayList to copy from | |
pos | the offset into the source list | |
size | the number of elements to copy |
Definition at line 296 of file arraylist.h.
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).
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 |
Definition at line 255 of file arraylist.h.
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).
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 |
Definition at line 255 of file arraylist.h.
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.
pos | the position where new elements should appear | |
inc | (optional) the number of elements to add |
Definition at line 822 of file arraylist.h.
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.
pos | the position where new elements should appear | |
inc | (optional) the number of elements to add |
Definition at line 822 of file arraylist.h.
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.
pos | the position where the new element should appear | |
src | the element to add |
Definition at line 845 of file arraylist.h.
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.
pos | the position where the new element should appear | |
src | the element to add |
Definition at line 845 of file arraylist.h.
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.
pos | the position where new elements should appear | |
inc | (optional) the number of elements to add |
Definition at line 796 of file arraylist.h.
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.
pos | the position where new elements should appear | |
inc | (optional) the number of elements to add |
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().
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.
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().
Access an element at position i.
Definition at line 1046 of file arraylist.h.
Access an element at position i.
Definition at line 1046 of file arraylist.h.
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)
dec | (optional) the number of elements to remove |
Definition at line 699 of file arraylist.h.
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)
dec | (optional) the number of elements to remove |
Definition at line 699 of file arraylist.h.
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.
dest | an uninitialized object to receive the element |
Definition at line 719 of file arraylist.h.
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.
dest | an uninitialized object to receive the element |
Definition at line 719 of file arraylist.h.
Referenced by MinHeap< double, Grain * >::PopOnly().
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.
dec | (optional) the number of elements to remove |
Definition at line 683 of file arraylist.h.
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.
dec | (optional) the number of elements to remove |
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().
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.
inc | (optional) the number of elements to add |
Definition at line 582 of file arraylist.h.
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.
inc | (optional) the number of elements to add |
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().
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.
src | the element to add |
Definition at line 603 of file arraylist.h.
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.
src | the element to add |
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().
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.
inc | (optional) the number of elements to add |
Definition at line 554 of file arraylist.h.
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.
inc | (optional) the number of elements to add |
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().
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.
Definition at line 343 of file arraylist.h.
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.
Definition at line 343 of file arraylist.h.
Referenced by DatasetInfo::ReadMatrix().
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.
pos | the position of the first element to remove | |
dec | (optional) the number of elements to remove |
Definition at line 945 of file arraylist.h.
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.
pos | the position of the first element to remove | |
dec | (optional) the number of elements to remove |
Definition at line 945 of file arraylist.h.
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.
pos | the position of the element to move | |
dest | an uninitialized object to receive the element |
Definition at line 967 of file arraylist.h.
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.
pos | the position of the element to move | |
dest | an uninitialized object to receive the element |
Definition at line 967 of file arraylist.h.
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.
pos | the position of the first element to remove | |
dec | (optional) the number of elements to remove |
Definition at line 930 of file arraylist.h.
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.
pos | the position of the first element to remove | |
dec | (optional) the number of elements to remove |
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().
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).
size | the needed minimum capacity of the array |
Definition at line 487 of file arraylist.h.
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).
size | the needed minimum capacity of the array |
Definition at line 487 of file arraylist.h.
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.
size | the new size for the array |
Definition at line 423 of file arraylist.h.
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.
size | the new size for the array |
Definition at line 423 of file arraylist.h.
Referenced by String::Append(), String::FixLength(), SimpleNaiveBayesClassifier::InitTrain(), DatasetInfo::ReadMatrix(), String::SetLength(), and String::Truncate().
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.
size | the number of elements to move | |
dest | an ArrayList to receive the elements |
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.
size | the number of elements to move | |
dest | an ArrayList to receive the elements |
Definition at line 1170 of file arraylist.h.
References ArrayList< TElem >::PushBackRaw(), and ArrayList< TElem >::SegmentInit().
void ArrayList< TElem >::SegmentInit | ( | index_t | size, | |
ArrayList< TElem > * | dest | |||
) |
Moves multiple elements from the end of an ArrayList to a new ArrayList.
size | the number of elements to move | |
dest | an uninitialized ArrayList to receive the elements |
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.
size | the number of elements to move | |
dest | an array of uninitialized objects to receive the elements |
Definition at line 744 of file arraylist.h.
void ArrayList< TElem >::SegmentInit | ( | index_t | size, | |
ArrayList< TElem > * | dest | |||
) | [inline] |
Moves multiple elements from the end of an ArrayList to a new ArrayList.
size | the number of elements to move | |
dest | an uninitialized ArrayList to receive the elements |
Definition at line 1163 of file arraylist.h.
References ArrayList< TElem >::InitRaw(), and ArrayList< TElem >::SegmentInit().
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.
size | the number of elements to move | |
dest | an array of uninitialized objects to receive the elements |
Definition at line 744 of file arraylist.h.
Referenced by ArrayList< TElem >::SegmentAppend(), and ArrayList< TElem >::SegmentInit().
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.
size | the decreased size; must be less than starting size |
Definition at line 403 of file arraylist.h.
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.
size | the decreased size; must be less than starting size |
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().
index_t ArrayList< TElem >::size | ( | ) | const [inline] |
The number of active elements in the ArrayList.
Definition at line 1026 of file arraylist.h.
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().
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.
size | a lower bound on the size for the array |
Definition at line 446 of file arraylist.h.
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.
size | a lower bound on the size for the array |
Definition at line 446 of file arraylist.h.
void ArrayList< TElem >::SizeAtMost | ( | index_t | size | ) | [inline] |
void ArrayList< TElem >::SizeAtMost | ( | index_t | size | ) | [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.
other | the ArrayList to exchange with |
Definition at line 361 of file arraylist.h.
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.
other | the ArrayList to exchange with |
Definition at line 361 of file arraylist.h.
Referenced by String::Swap(), ArrayList< std::pair< index_t, index_t > >::Swap(), and RangeSet< TBoundary >::Union().
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).
Definition at line 509 of file arraylist.h.
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).
Definition at line 509 of file arraylist.h.
Referenced by DatasetInfo::ReadMatrix(), and String::Trim().