SubsetNew (NamedArraylist function): Difference between revisions
m (match syntax table to syntax template, tags and edits) |
mNo edit summary |
||
Line 12: | Line 12: | ||
<tr><th>selectionCriterion</th> | <tr><th>selectionCriterion</th> | ||
<td>A <var>SelectionCriterion</var> object, which is a relational expression that is applied to a <var class="term">nal</var> item value to determine whether the value satisfies the expression. The expression consists of a function, an operator, and a numeric or string value. | <td>A <var>SelectionCriterion</var> object, which is a relational expression that is applied to a <var class="term">nal</var> item value to determine whether the value satisfies the expression. The expression consists of a function, an operator, and a numeric or string value. | ||
<p>For example, <code>GT(this, -11)</code> is the criterion <code>this > -11</code>, where < | <p>For example, <code>GT(this, -11)</code> is the criterion <code>this > -11</code>, where <var>this</var> is an identity function value that simply returns the item's value. The items that satisfy this expression populate the <var>NamedArraylist</var> that <var>SubsetNew</var> returns.</p> | ||
<p>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 <var class="term">nal</var> declaration and that returns a numeric or string value. This is described further in [[SelectionCriterion class#Specifying a SelectionCriterion's parameters|"Specifying a SelectionCriterion's parameters"]].</p></td></tr> | <p>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 <var class="term">nal</var> declaration and that returns a numeric or string value. This is described further in [[SelectionCriterion class#Specifying a SelectionCriterion's parameters|"Specifying a SelectionCriterion's parameters"]].</p></td></tr> | ||
Revision as of 17:52, 3 May 2011
Create NamedArraylist of items matching some selection criteria (NamedArraylist class)
SubsetNew searches the entire NamedArraylist 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 NamedArraylist.
Syntax
%outNal = nal:SubsetNew( selectionCriterion)
Syntax terms
%outNal | A NamedArraylist variable of the same type as the method NamedArraylist (Nal) to contain the items that are located by the search. If outNal is not empty, its contents are discarded before it is populated by the items returned from SubsetNew. |
---|---|
nal | A NamedArraylist object. |
selectionCriterion | A SelectionCriterion object, which is a relational expression that is applied to a nal 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 nal 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
- In the following fragment, a SubsetNew call is applied to a collection of objects of the
staff
class that is defined in the request in the NamedArraylist FindNextItem "Examples" section:%old is namedArraylist of object staff %old = new %old('Jim') = newf('Red', 'employed') %old('Jed') = newf('Black', 'retired') %old('Jan') = newf('Green', 'employed') %old('Jud') = newf('Brown', 'retired') %old('Jon') = newf('White', 'retired') %sel is object selectioncriterion for object staff %sel = AND(LT(name, 'Mud'), EQ(status, 'retired')) %fnd is namedArraylist of object staff %fnd = %old:SubsetNew(%sel) %fnd:Print(name, separator=' ')
The result is:
1 Jed Black 2 Jud Brown
See also
- FindNextItem is similar to SubsetNew except that it returns just the first matching item it encounters.