SubsetNew (FloatNamedArraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Return all matching FloatNamedArrayl<section end=dpl_desc/></b></span> [[Category:FloatNamedArraylist method...")
 
 
(19 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Return all matching FloatNamedArrayl<section end=dpl_desc/></b></span>
{{Template:FloatNamedArraylist:SubsetNew subtitle}}
[[Category:FloatNamedArraylist methods|SubsetNew function]]
<var>SubsetNew</var> searches the entire <var>FloatNamedArraylist</var> to find and return all items that match a specified criterion.  The criterion is supplied by the <var>[[SelectionCriterion class|SelectionCriterion]]</var> object that is the required <var>SubsetNew</var> parameter.  If no item satisfies the criterion, <var>SubsetNew</var> returns an empty <var>FloatNamedArraylist</var>.
<!--DPL?? Category:FloatNamedArraylist methods|SubsetNew function: Return all matching FloatNamedArrayl-->
<p>
SubsetNew is a member of the [[FloatNamedArraylist class]].
</p>


This function searches the entire FloatNamedArraylist to find and return
all items that match a specified criterion.
The criterion is supplied by the [[SelectionCriterion class|SelectionCriterion]] object
that is the required SubsetNew parameter.
If no item satisfies the criterion, SubsetNew returns an empty FloatNamedArraylist.
SubsetNew is available in ''Sirius Mods'' version 7.6 and later.
==Syntax==
==Syntax==
  %fnamraylNew = %fnamrayl:SubsetNew(criterion)
{{Template:FloatNamedArraylist:SubsetNew syntax}}
===Syntax Terms===
===Syntax terms===
<dl>
<table class="syntaxTable">
<dt><i>%fnamraylNew</i>
<tr><th>%outFltNal</th>
<dd>A FloatNamedArraylist variable of the same type as the method FloatNamedArraylist
<td>A <var>FloatNamedArraylist</var> variable of the same type as the method <var>FloatNamedArraylist</var>(<var class="term">fltNal</var>) to contain the items that are located by the search. If <var class="term">outFltNal</var> is not empty, its contents are discarded before it is populated by the items returned from <var>SubsetNew</var>. </td></tr>
(''%fnamrayl'') to contain the items that are located by the search.
<tr><th>fltNal</th>
If ''%fnamraylNew'' is not empty, its contents are discarded before it
<td>A <var>FloatNamedArraylist</var> object. </td></tr>
is populated by the return items from SubsetNew.
<tr><th>selectionCriterion</th>
<dt><i>%fnamrayl</i>
<td>A <var>SelectionCriterion</var> object, which is a relational expression that is applied to a <var class="term">fltNal</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.
<dd>A FloatNamedArraylist object.
<p>For example, <code>LT(this, -11)</code> is the criterion <code>this < -11</code>, where <code>this</code> is an identity function that simply returns the item's value. The items that satisfy this expression populate the <var>FloatNamedArraylist</var> that <var>SubsetNew</var> returns.</p>
<dt><i>criterion</i>
<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">fltNal</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>
<dd>A SelectionCriterion object, which is a relational expression that is
applied to a ''%fnamrayl'' 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, <tt>LT(this, -11)</tt> is the
</table>
criterion <tt>this</tt> <tt><</tt> <tt>-11</tt>, where
==Usage notes==
<tt>this</tt> is an identity function that simply returns the item's value.
The items that satisfy this expression populate the
FloatNamedArraylist that SubsetNew returns.
 
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 ''%fnamrayl''
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]]".
 
</dl>
==Usage Notes==
<ul>
<ul>
<li>[[FindNextItem (FloatNamedArraylist function)|FindNextItem]]
<li><var>SubsetNew</var> is available in <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.6 and later.
is similar to SubsetNew except that it returns just the first matching item
it encounters.
</ul>
</ul>
==Examples==
==Examples==
In the following fragment, a <var>SubsetNew</var> call is applied to a <var>FloatNamedArraylist</var> of objects of the <code>annual</code> class that is defined in the request in the [[Minimum (FloatNamedArraylist function)#Examples|"FloatNamedArraylist Minimum function example"]].
<p class="code">%fann is floatnamedArraylist of object annual
%fannNew is floatnamedArraylist of object annual
%fann = new
%fann(12) = newa(621, 650)
%fann(14) = newa(334, 343)
%fann(15) = newa(288, 276)
%fann(13) = newa(141, 182)
%fann(11) = newa(131, 115)


In the following fragment, a SubsetNew call is applied to a
%sel is object selectionCriterion for object annual
FloatNamedArraylist
%sel = LT(chg, 0)
of objects of the <tt>annual</tt> class that is defined in the
request in the [[Minimum (FloatNamedArraylist function)#Examples|FloatNamedArraylist Minimum function example]].
<pre style="xmp">
    %fann is floatnamedArraylist of object annual
    %fannNew is floatnamedArraylist of object annual
    %fann = new
    %fann(12) = newa(621, 650)
    %fann(14) = newa(334, 343)
    %fann(15) = newa(288, 276)
    %fann(13) = newa(141, 182)
    %fann(11) = newa(131, 115)


    %sel is object selectionCriterion for object annual
%fannNew = %fann:findSubsetNew(%sel)
    %sel = LT(chg, 0)
%fannNew:print(myprint)
</p>
The result shows the default print formatting of item number (position) and item name (float) followed by colons, then the item value (<code>myprint</code> output):
<p class="code">1: 12: ybegin=621, yend=650
2: 13: ybegin=141, yend=182
3: 14: ybegin=334, yend=343
</p>


    %fannNew = %fann:findSubsetNew(%sel)
==See also==
    %fannNew:print(myprint)
<ul><li><var>[[FindNextItem (FloatNamedArraylist function)|FindNextItem]]</var> is similar to <var>SubsetNew</var> except that it returns just the first matching item it encounters.
</pre>
<li>The <var>NamedArraylist</var> <var>[[SubsetNew (NamedArraylist function)|SubsetNew]]</var> and <var>UnicodeNamedArraylist</var> <var>[[SubsetNew (UnicodeNamedArraylist function)|SubsetNew]]</var> functions also perform the subsetting function &mdash; for their respective classes. The examples on those pages may provide additional approaches for <var>SubsetNew</var>.
 
</ul>
The result shows the default print formatting of item number (position)
{{Template:FloatNamedArraylist:SubsetNew footer}}
and item name (float)
followed by colons, then the item value (<tt>myprint</tt> output):
<pre style="xmp">
    1: 12: ybegin=621, yend=650
    2: 13: ybegin=141, yend=182
    3: 14: ybegin=334, yend=343
</pre>

Latest revision as of 20:39, 1 November 2012

Create NamedArraylist of items matching some selection criteria (FloatNamedArraylist class)

SubsetNew searches the entire FloatNamedArraylist 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 FloatNamedArraylist.

Syntax

%outFltNal = fltNal:SubsetNew( selectionCriterion)

Syntax terms

%outFltNal A FloatNamedArraylist variable of the same type as the method FloatNamedArraylist(fltNal) to contain the items that are located by the search. If outFltNal is not empty, its contents are discarded before it is populated by the items returned from SubsetNew.
fltNal A FloatNamedArraylist object.
selectionCriterion A SelectionCriterion object, which is a relational expression that is applied to a fltNal 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, LT(this, -11) is the criterion this < -11, where this is an identity function that simply returns the item's value. The items that satisfy this expression populate the FloatNamedArraylist that SubsetNew returns.

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 fltNal 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 FloatNamedArraylist of objects of the annual class that is defined in the request in the "FloatNamedArraylist Minimum function example".

%fann is floatnamedArraylist of object annual %fannNew is floatnamedArraylist of object annual %fann = new %fann(12) = newa(621, 650) %fann(14) = newa(334, 343) %fann(15) = newa(288, 276) %fann(13) = newa(141, 182) %fann(11) = newa(131, 115) %sel is object selectionCriterion for object annual %sel = LT(chg, 0) %fannNew = %fann:findSubsetNew(%sel) %fannNew:print(myprint)

The result shows the default print formatting of item number (position) and item name (float) followed by colons, then the item value (myprint output):

1: 12: ybegin=621, yend=650 2: 13: ybegin=141, yend=182 3: 14: ybegin=334, yend=343

See also

  • FindNextItem is similar to SubsetNew except that it returns just the first matching item it encounters.
  • The NamedArraylist SubsetNew and UnicodeNamedArraylist SubsetNew functions also perform the subsetting function — for their respective classes. The examples on those pages may provide additional approaches for SubsetNew.