<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://m204wiki.rocketsoftware.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Curly</id>
	<title>m204wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://m204wiki.rocketsoftware.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Curly"/>
	<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Special:Contributions/Curly"/>
	<updated>2026-04-10T06:26:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Add_(Arraylist_function)&amp;diff=14104</id>
		<title>Add (Arraylist function)</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Add_(Arraylist_function)&amp;diff=14104"/>
		<updated>2011-03-14T20:11:36Z</updated>

		<summary type="html">&lt;p&gt;Curly: /* Syntax terms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Arraylist:Add subtitle}}&lt;br /&gt;
&amp;lt;var&amp;gt;Add&amp;lt;/var&amp;gt; adds an item to the end of an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
{{Template:Arraylist:Add syntax}}&lt;br /&gt;
===Syntax terms===&lt;br /&gt;
&amp;lt;table class=&amp;quot;syntaxTable&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%count&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An, optional, numeric variable that returns the number of items in the indicated &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; after the items have been added. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%count&amp;lt;/var&amp;gt; is also the item number associated with the last or only added item in the &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;al&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; object. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;itemList&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.9 and later this can be a comma-delimited set of values or variables of the same type as specified on the &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;al&amp;lt;/var&amp;gt; declaration or collections of objects of the same type as specified on the &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;al&amp;lt;/var&amp;gt; declaration. Each of these, from left to right, becomes an item or items in the method object &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.8 and earlier &amp;lt;var&amp;gt;itemList&amp;lt;/var&amp;gt; can only be a single value or variable of the same type as specified on the &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;al&amp;lt;/var&amp;gt; declaration, or a value or variable convertible to that type to be added to the &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;al&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
Of course, a single value or variable is just a single item list so can be specified under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.9 and later, too.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage notes==&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;The &amp;lt;var&amp;gt;[[Push (Arraylist function)|Push]]&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;[[Enqueue (Arraylist function)|Enqueue]]&amp;lt;/var&amp;gt; functions are the same as the &amp;lt;var&amp;gt;Add&amp;lt;/var&amp;gt; function with the exception that &amp;lt;var&amp;gt;Push&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;Enqueue&amp;lt;/var&amp;gt; can only add a single item to the target &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; while (under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.9 and later) &amp;lt;var&amp;gt;Add&amp;lt;/var&amp;gt; can add many items to the target &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;Push&amp;lt;/var&amp;gt; was designed as a convenience for use with the &amp;lt;var&amp;gt;[[Pop (Arraylist function)|Pop]]&amp;lt;/var&amp;gt; function.&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;Enqueue&amp;lt;/var&amp;gt; was designed as a convenience for use with the &amp;lt;var&amp;gt;[[Dequeue (Arraylist function)|Dequeue]]&amp;lt;/var&amp;gt; function.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
For more examples of &amp;lt;var&amp;gt;Add&amp;lt;/var&amp;gt; calls, see [[Arraylist class]].&lt;br /&gt;
===Adding numbers to an Arraylist===&lt;br /&gt;
In the following example, a literal number, a numeric variable and another &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; of numbers is added to an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;b&lt;br /&gt;
&lt;br /&gt;
%nums     is arraylist of float&lt;br /&gt;
%perfect  is float&lt;br /&gt;
%primes   is arraylist of float&lt;br /&gt;
&lt;br /&gt;
%nums = list(0, 1)&lt;br /&gt;
%perfect = 6&lt;br /&gt;
%primes  = list(2, 3, 5, 7, 11, 13, 17, 23)&lt;br /&gt;
&lt;br /&gt;
%nums:add(16, %perfect, %primes)&lt;br /&gt;
%nums:print&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This outputs:&lt;br /&gt;
&amp;lt;p class=&amp;quot;output&amp;quot;&amp;gt;1: 0&lt;br /&gt;
2: 1&lt;br /&gt;
3: 16&lt;br /&gt;
4: 6&lt;br /&gt;
5: 2&lt;br /&gt;
6: 3&lt;br /&gt;
7: 5&lt;br /&gt;
8: 7&lt;br /&gt;
9: 11&lt;br /&gt;
10: 13&lt;br /&gt;
11: 17&lt;br /&gt;
12: 23&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Adding objects to an Arraylist===&lt;br /&gt;
In the following example, a new object, an object variable and another &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; of objects is added to an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;b&lt;br /&gt;
&lt;br /&gt;
class coordinate&lt;br /&gt;
   public&lt;br /&gt;
      constructor new(%x is float, %y is float)&lt;br /&gt;
      function toString is longstring&lt;br /&gt;
      variable x is float&lt;br /&gt;
      variable y is float&lt;br /&gt;
   end public&lt;br /&gt;
   constructor new(%x is float, %y is float)&lt;br /&gt;
      %this:x = %x; %this:y = %y&lt;br /&gt;
   end constructor&lt;br /&gt;
   function toString is longstring&lt;br /&gt;
      returnText coordinate: x={%x}, y={%y}&lt;br /&gt;
   end function&lt;br /&gt;
end class&lt;br /&gt;
&lt;br /&gt;
%points    is arraylist of object coordinate&lt;br /&gt;
%where     is object coordinate&lt;br /&gt;
%locations is arraylist of object coordinate&lt;br /&gt;
&lt;br /&gt;
%points    = list(new(6, 9), new(-4, 3))&lt;br /&gt;
%where     = new(17, -3)&lt;br /&gt;
%locations = list(new(1, 1), new(2, 5), new(3, 11))&lt;br /&gt;
&lt;br /&gt;
%points:add(new(4, 3), %where, %locations)&lt;br /&gt;
&lt;br /&gt;
%points:print&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This outputs:&lt;br /&gt;
&amp;lt;p class=&amp;quot;output&amp;quot;&amp;gt;1: coordinate: x=6, y=9&lt;br /&gt;
2: coordinate: x=-4, y=3&lt;br /&gt;
3: coordinate: x=4, y=3&lt;br /&gt;
4: coordinate: x=17, y=-3&lt;br /&gt;
5: coordinate: x=1, y=1&lt;br /&gt;
6: coordinate: x=2, y=5&lt;br /&gt;
7: coordinate: x=3, y=11&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Template:Arraylist:Add footer}}&lt;/div&gt;</summary>
		<author><name>Curly</name></author>
	</entry>
</feed>