SubsetNew (Arraylist function): Difference between revisions
m (very minor) |
m (see also) |
||
Line 15: | Line 15: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul><li><var>SubsetNew</var> is available in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.6 and later. | ||
<li><var>SubsetNew</var> is available in <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.6 and later. | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
<ol> | <ol><li>The following request contains two <var>SubsetNew</var> calls, one with a simple selection criterion and one with a compound criterion: | ||
<li>The following request contains two <var>SubsetNew</var> calls, one with a simple selection criterion and one with a compound criterion: | |||
<p class="code">begin | <p class="code">begin | ||
%al is arraylist of float | %al is arraylist of float | ||
Line 56: | Line 52: | ||
==See also== | ==See also== | ||
<ul><li><var>[[FindNextItem (Arraylist function)|FindNextItem]]</var> without the <var class="term">Start</var> argument is similar to <var>SubsetNew</var> except that it returns just the first matching item it encounters. | |||
</ul> | |||
{{Template:Arraylist:SubsetNew footer}} | {{Template:Arraylist:SubsetNew footer}} |
Revision as of 05:48, 11 March 2011
Return all matching Arraylist items (Arraylist class)
SubsetNew searches the entire Arraylist to find and return all items that match a specified criterion. The criterion is supplied by the SelectionCriterion object that is the required SubsetNew parameter. If no item satisfies the criterion, SubsetNew returns an empty Arraylist.
Syntax
%newList = al:SubsetNew( selectionCriterion)
Syntax terms
%newList | An Arraylist variable of the same type as the method Arraylist (al) to receive the items that are located by the search. If %newList is not empty, its contents are discarded before it is populated by any items returned from SubsetNew. |
---|---|
al | An Arraylist object. |
selectionCriterion | A SelectionCriterion object, which is a relational expression that is applied to an al item value to determine whether the value satisfies the expression. The expression consists of a function, an operator, and a numeric or string value. For example, The function in the criterion is a method value (a method or class member name literal, or a method variable) for a method that operates on items of the type specified on the al declaration and that returns a numeric or string value. This is described further in "Specifying a SelectionCriterion's parameters". |
Usage notes
- SubsetNew is available in "Sirius Mods" Version 7.6 and later.
Examples
- The following request contains two SubsetNew calls, one with a simple selection criterion and one with a compound criterion:
begin %al is arraylist of float %alnew is arraylist of float %al = list(111, 29, 0, 93, 77, -345) %sel1 is object selectioncriterion for float %sel2 is object selectioncriterion for float %sel1 = GT(this, 0) %sel2 = AND(GE(this, 50), LT(this, 93)) %alnew = %al:SubsetNew(%sel1) Print 'The result of selection1 is:' %alnew:print %alnew = %al:SubsetNew(%sel2) print 'The result of selection2 is:' %alnew:print end
The result is:
The result of selection1 is: 1: 111 2: 29 3: 93 4. 77 The result of selection2 is: 1: 93 2: 77
See also
- FindNextItem without the Start argument is similar to SubsetNew except that it returns just the first matching item it encounters.