SubsetNew (UnicodeNamedArraylist 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 collection ite<section end=dpl_desc/></b></span> [[Category:UnicodeNamedArraylist method...")
 
 
(18 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 collection ite<section end=dpl_desc/></b></span>
{{Template:UnicodeNamedArraylist:SubsetNew subtitle}}
[[Category:UnicodeNamedArraylist methods|SubsetNew function]]
<var>SubsetNew</var> searches the entire <var>UnicodeNamedArraylist</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>UnicodeNamedArraylist</var>.
<!--DPL?? Category:UnicodeNamedArraylist methods|SubsetNew function: Return all matching collection ite-->
 
<p>
==Syntax==
SubsetNew is a member of the [[UnicodeNamedArraylist class]].
{{Template:UnicodeNamedArraylist:SubsetNew syntax}}
===Syntax terms===
<table class="syntaxTable">
<tr><th>%outUniNal</th>
<td>A <var>UnicodeNamedArraylist</var> variable of the same type as the method <var>UnicodeNamedArraylist</var> (<var class="term">uniNal</var>) to contain the items that are located by the search. If <var class="term">outUniNal</var> is not empty, its contents are discarded before it is populated by the items returned from <var>SubsetNew</var>. </td></tr>
<tr><th>uniNal</th>
<td>A <var>UnicodeNamedArraylist</var> object. </td></tr>
<tr><th>selectionCriterion</th>
<td>A <var>[[SelectionCriterion class|SelectionCriterion]]</var> object, which is a relational expression that is applied to a <var class="term">uniNal</var> item value to determine whether the value satisfies the expression. The expression consists of a function, an operator, and a <var class="product">User Language</var> intrinsic type (numeric, string, or Unicode) value.
<p>For example, <code>LT(this, 91)</code> is the criterion <code>this < 91</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>UnicodeNamedArraylist</var> that <var>SubsetNew</var> returns.
</p>
</p>
<p>The function in the criterion is a method value (a method or class member name literal, or a [[Method variables|method variable]]) for a method that operates on items of the type specified on the <var class="term">uniNal</var> declaration and that returns an intrinsic value. This is described further in [[SelectionCriterion class#Specifying a SelectionCriterion's parameters|"Specifying a SelectionCriterion's parameters"]].
</p></td></tr>
</table>


This function searches the entire UnicodeNamedArraylist to find and return
==Examples==
all items that match a specified criterion.
In the following request, a <var>SubsetNew</var> call uses a selection criterion that first applies the intrinsic [[Length (String function)|Length]] function to the collection items:
The criterion is supplied by the [[SelectionCriterion class|SelectionCriterion]] object
<p class="code">begin
that is the required SubsetNew parameter.
  %k  is unicodeNamedArraylist of longstring
If no item satisfies the criterion, SubsetNew returns an empty UnicodeNamedArraylist.
  %kk  is unicodeNamedArraylist of longstring
==Syntax==
  %k = new
   %unamraylNew = %unamrayl:SubsetNew(criterion)
   %k('&sect;Jan':u) = 'Orion'
===Syntax Terms===
  %k('&sect;Apr':u) = 'Leo'
<dl>
  %k('&sect;Mar':u) = 'Cancer'
<dt><i>%unamraylNew</i>
  %k('&sect;Jun':u) = 'Ursa Minor'
<dd>A UnicodeNamedArraylist variable of the same type as the method
  %k('&sect;Nov':u) = 'Andromeda'
UnicodeNamedArraylist (''%unamrayl'') to contain the items that are
  %k('&sect;Dec':u) = 'Aries'
located by the search.
  %k('&sect;Feb':u) = 'Canis Major'
If ''%unamraylNew'' is not empty, its contents are discarded before it
is populated by the return items from SubsetNew.
<dt><i>%unamrayl</i>
<dd>A UnicodeNamedArraylist object.
<dt><i>criterion</i>
<dd>A SelectionCriterion object, which is a relational expression that is
applied to a ''%unamrayl'' item value to determine
whether the value satisfies the expression.
The expression consists of a function, an operator, and a User Language intrinsic type
(numeric, string, or Unicode) value.


For example, <tt>LT(this, 91)</tt> is the
  %sel is object selectionCriterion for longstring
criterion <tt>this</tt> <tt><</tt> <tt>91</tt>, where
  %n is float
<tt>this</tt> is an identity function that simply returns the item's value.
  %sel = GE(length, 9)
The items that satisfy this expression populate the
UnicodeNamedArraylist that SubsetNew returns.


The function in the criterion is
  %kk = %k:subsetNew(%sel)
a method value (a method or class member name literal, or a method variable)
  %kk:print
for a method
end
that operates on items of the type specified on the ''%unamrayl''
</p>
declaration and that returns an intrinsic value.
The result is:
This is described further in "[[SelectionCriterion class#Specifying a SelectionCriterion's parameters|Specifying a SelectionCriterion's parameters]]".
<p class="output">1: &sect.Feb: Canis Major
2: &sect.Jun: Ursa Minor
3: &sect.Nov: Andromeda
</p>


</dl>
==See also==
==Usage Notes==
<ul>
<ul>
<li>[[FindNextItem (UnicodeNamedArraylist function)|FindNextItem]]
<li><var>[[FindNextItem (UnicodeNamedArraylist function)|FindNextItem]]</var> is similar to <var>SubsetNew</var> except that it returns just the first matching item it encounters.
is similar to SubsetNew except that it returns just the first matching item
<li>The <var>NamedArraylist</var> <var>[[SubsetNew (NamedArraylist function)|SubsetNew]]</var> and <var>FloatNamedArraylist</var> <var>[[SubsetNew (FloatNamedArraylist function)|SubsetNew]]</var> functions also perform the subsetting function &mdash; for their respective classes. The examples on those pages may provide for possible additional approaches for <var>SubsetNew</var>.
it encounters.
</ul>
</ul>
==Examples==
{{Template:UnicodeNamedArraylist:SubsetNew footer}}
 
In the following request, a SubsetNew call uses a selection criterion
that first applies the intrinsic [[Length (String function)|Length]] function
to the collection items:
<pre style="xmp">
    Begin
 
    %k  is unicodeNamedArraylist of longstring
    %kk  is unicodeNamedArraylist of longstring
    %k = new
    %k('&sect;Jan':u) = 'Orion'
    %k('&sect;Apr':u) = 'Leo'
    %k('&sect;Mar':u) = 'Cancer'
    %k('&sect;Jun':u) = 'Ursa Minor'
    %k('&sect;Nov':u) = 'Andromeda'
    %k('&sect;Dec':u) = 'Aries'
    %k('&sect;Feb':u) = 'Canis Major'
 
    %sel is object selectionCriterion for longstring
    %n is float
    %sel = GE(length, 9)
 
    %kk = %k:subsetNew(%sel)
    %kk:print
 
    End
</pre>
 
The result is:
<pre style="xmp">
    1: &sect.Feb: Canis Major
    2: &sect.Jun: Ursa Minor
    3: &sect.Nov: Andromeda
</pre>

Latest revision as of 16:39, 3 August 2012

Create UnicodeNamedArraylist of items matching some selection criteria (UnicodeNamedArraylist class)

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

Syntax

%outUniNal = uniNal:SubsetNew( selectionCriterion)

Syntax terms

%outUniNal A UnicodeNamedArraylist variable of the same type as the method UnicodeNamedArraylist (uniNal) to contain the items that are located by the search. If outUniNal is not empty, its contents are discarded before it is populated by the items returned from SubsetNew.
uniNal A UnicodeNamedArraylist object.
selectionCriterion A SelectionCriterion object, which is a relational expression that is applied to a uniNal item value to determine whether the value satisfies the expression. The expression consists of a function, an operator, and a User Language intrinsic type (numeric, string, or Unicode) value.

For example, LT(this, 91) is the criterion this < 91, where this is an identity function that simply returns the item's value. The items that satisfy this expression populate the UnicodeNamedArraylist 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 uniNal declaration and that returns an intrinsic value. This is described further in "Specifying a SelectionCriterion's parameters".

Examples

In the following request, a SubsetNew call uses a selection criterion that first applies the intrinsic Length function to the collection items:

begin %k is unicodeNamedArraylist of longstring %kk is unicodeNamedArraylist of longstring %k = new %k('§Jan':u) = 'Orion' %k('§Apr':u) = 'Leo' %k('§Mar':u) = 'Cancer' %k('§Jun':u) = 'Ursa Minor' %k('§Nov':u) = 'Andromeda' %k('§Dec':u) = 'Aries' %k('§Feb':u) = 'Canis Major' %sel is object selectionCriterion for longstring %n is float %sel = GE(length, 9) %kk = %k:subsetNew(%sel) %kk:print end

The result is:

1: &sect.Feb: Canis Major 2: &sect.Jun: Ursa Minor 3: &sect.Nov: Andromeda

See also

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