<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FCommunity%2FScripting%2FClasses%2Farray</id>
	<title>HPL3/Community/Scripting/Classes/array - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FCommunity%2FScripting%2FClasses%2Farray"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Community/Scripting/Classes/array&amp;action=history"/>
	<updated>2026-05-14T16:54:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/Community/Scripting/Classes/array&amp;diff=2115&amp;oldid=prev</id>
		<title>Maintenance script: Upload classes to sub</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/Community/Scripting/Classes/array&amp;diff=2115&amp;oldid=prev"/>
		<updated>2020-07-30T09:11:13Z</updated>

		<summary type="html">&lt;p&gt;Upload classes to sub&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==array &amp;lt;typename T&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Fields===&lt;br /&gt;
&lt;br /&gt;
array &amp;lt;typename T&amp;gt; has no public fields.&lt;br /&gt;
&lt;br /&gt;
===Functions===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=1&lt;br /&gt;
! Return Type !! Function Name !! Parameters !! Description &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  insertAt  ||  uint alIndex, &amp;lt;br /&amp;gt;const T &amp;amp;in aValue  ||  Inserts the value at the specified index, shifting existing values to the right. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  removeAt  ||  uint alIndex  ||  Removes the value at the specified index, shifting values after the index to the left. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  insertLast  ||  const T &amp;amp;in aValue  ||  Inserts the value into a new index at the end of the array.  &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  insertBack  ||  const T &amp;amp;in aValue  ||  ''%%'''Using this function results in an error.'''%%'' &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  removeFirst  ||       ||  Removes the value at the beginning of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  removeLast  ||       ||  Removes the value at the end of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  uint  ||  length  ||       ||  Returns the number of elements within the array. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  resize  ||  uint alLength  ||  Resizes the array to the specified size, creating or removing elements as necessary. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  sortAsc  ||       ||  Sorts all elements in the array into ascending order. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  sortAsc  ||  uint alIndex, &amp;lt;br /&amp;gt;uint alLength  ||  Sorts elements in the array into ascending order, affecting only the subsection at the given index to the given length. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  sortDesc  ||       ||  Sorts all elements in the array into descending order. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  sortDesc  ||  uint alIndex, &amp;lt;br /&amp;gt;uint alLength  ||  Sorts elements in the array into descending order, affecting only the subsection at the given index to the given length. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  reverse  ||       ||  Reverses the order of elements in the array. &lt;br /&gt;
|-&lt;br /&gt;
|  int  ||  find  ||  const T &amp;amp;in aValue  ||  Returns the index of the first element in the array equal to the given value, or -1 if the value was not found. &lt;br /&gt;
|-&lt;br /&gt;
|  int  ||  find  ||  uint alIndex, &amp;lt;br /&amp;gt;const T &amp;amp;in aValue  ||  Returns the index of the first element in the array equal to the given value, or -1 if the value was not found. Only affects elements starting at the given index. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  push_back  ||  const T &amp;amp;in aValue  ||  Inserts the given value at the end of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  push_front  ||  const T &amp;amp;in aValue  ||  Inserts the given value at the beginning of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  pop_back  ||       ||  Removes the element at the end of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  void  ||  pop_front  ||       ||  Removes the element at the beginning of the array. &lt;br /&gt;
|-&lt;br /&gt;
|  uint  ||  size  ||       ||  Returns the number of elements within the array. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Remarks===&lt;br /&gt;
&lt;br /&gt;
The array class is unique in the HPL3 API in that it uses what is called a generic template. What this means is, when you create an array, you need to specify what variable type the array will be holding. This ensures that all objects within a given array are guaranteed to be of that type, eliminating the need for redundant conversions and type checks.&lt;br /&gt;
&lt;br /&gt;
To declare an array, you put the type the array will be holding between a less than operator ( &amp;lt; ) and a greater than operator ( &amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;// An array of integers&lt;br /&gt;
array&amp;lt;int&amp;gt; mvIntegerArray;&lt;br /&gt;
&lt;br /&gt;
// An array of floats&lt;br /&gt;
array&amp;lt;float&amp;gt; mvFloatArray;&lt;br /&gt;
&lt;br /&gt;
// An array of strings&lt;br /&gt;
array&amp;lt;tString&amp;gt; mvStringArray;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are a number of ways to add values to your array. The simplest way is to use the push_back function. This automatically puts the given value at the end of the array.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;mvIntegerArray.push_back(5);&lt;br /&gt;
mvIntegerArray.push_back(2);&lt;br /&gt;
mvIntegerArray.push_back(11);&lt;br /&gt;
&lt;br /&gt;
'' The contents of mvIntegerArray: { 5, 2, 11 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another common way is to assign a value to an existing index within the array, using the square bracket ( [ ] ) syntax. (Indeces start at 0.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;mvIntegerArray[0] = 29;&lt;br /&gt;
mvIntegerArray[2] = -12;&lt;br /&gt;
&lt;br /&gt;
'' The contents of mvIntegerArray: { 29, 2, -12 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To retrieve an element from within the array, use the square bracket ([]) syntax with an integer index.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;int lIntValue = mvIntegerArray[0];&lt;br /&gt;
&lt;br /&gt;
'' The value of lIntvalue: 29&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Trying to assign a value to or retrieve a value from an index that does not exist in the array will result in an error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;// If the index at [100] doesn't exist, both of these lines&lt;br /&gt;
// of code will throw an error.&lt;br /&gt;
mvIntegerArray[100] = 5;&lt;br /&gt;
int lIntValue = mvIntegerArray[100];&lt;br /&gt;
&lt;br /&gt;
// However, the following code will work just fine&lt;br /&gt;
mvIntegerArray.resize(101);&lt;br /&gt;
mvIntegerArray[100] = 5;&lt;br /&gt;
int lIntValue = mvIntegerArray[100];&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>