Arraylist class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Created page with "<!-- Arraylist class --> Arraylists can be thought of as traditional arrays with no bounds and much more flexibility. For background information about collections and Arraylist...")
 
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- Arraylist class -->
<!-- Arraylist class -->
Arraylists can be thought of as traditional arrays with no bounds and
An <var>Arraylist</var> can be thought of as a traditional array with no bounds and
much more flexibility.
much more flexibility.
 
The following code shows several of the <var>Arraylist</var> methods:
<p class="code">%alist  is collection Arraylist of longstring
%i      is float
   
   
For background information about collections and Arraylists and about
%alist = new
declaring Arraylist object variables,
%alist:add('Idle')
see [[Collections]].
%alist:add('Gumby')
See also [[Collections#Coding considerations for collections|Coding
%alist:add('Chapman')
considerations for collections]].
%alist:add('Pallin')
%alist:insert(2, 'Jones')
The following code illustrates several of the Arraylist methods:
%alist:removeItem(4)
<pre style="xmp">
%alist(3) = 'Cleese'
    %alist  is collection Arraylist of longstring
for %i from 1 to %alist:count
    %i      is float
  print %alist(%i)
end for
    %alist = new
</p>
    %alist:add('Idle')
    %alist:add('Gumby')
    %alist:add('Chapman')
    %alist:add('Pallin')
    %alist:insert(2, 'Jones')
    %alist:removeItem(4)
    %alist(3) = 'Cleese'
    for %i from 1 to %alist:count
        print %alist(%i)
    end for
</pre>
This code snippet would print:
This code snippet would print:
<pre style="xmp">
<p class="output">Idle
    Idle
Jones
    Jones
Cleese
    Cleese
Pallin
    Pallin
</p>
</pre>
   
   
The individual Arraylist methods are described in the following subsections.
==List of Arraylist methods==
In the method templates, <tt>%arrayl</tt> is used to represent the object
The [[List of Arraylist methods|"List of Arraylist methods"]] shows all the class methods, with a brief description of each.
to which the method is being applied, sometimes called the &ldquo;method
 
object&rdquo;
==See also==
or the &ldquo;method Arraylist.&rdquo;
<table class="thJustBold">
Additional conventions are described in [[Notation conventions for methods]].
<tr><th>[[Collections]]</th>
<td>For background information about collections and <var>Arraylist</var>s and about
declaring <var>Arraylist</var> object variables.</td></tr>
<tr><th>[[Collections#Coding considerations for collections|Coding
considerations for collections]]</th>
<td>For tips on using collections.</td></tr>
</table>
 
[[Category:System classes]]
[[Category:System classes]]

Latest revision as of 21:25, 26 June 2013

An Arraylist can be thought of as a traditional array with no bounds and much more flexibility.

The following code shows several of the Arraylist methods:

%alist is collection Arraylist of longstring %i is float %alist = new %alist:add('Idle') %alist:add('Gumby') %alist:add('Chapman') %alist:add('Pallin') %alist:insert(2, 'Jones') %alist:removeItem(4) %alist(3) = 'Cleese' for %i from 1 to %alist:count print %alist(%i) end for

This code snippet would print:

Idle Jones Cleese Pallin

List of Arraylist methods

The "List of Arraylist methods" shows all the class methods, with a brief description of each.

See also

Collections For background information about collections and Arraylists and about declaring Arraylist object variables.
Coding considerations for collections For tips on using collections.