CountSubset (GenericNamedArraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 16: Line 16:


<tr><th>selectionCriterion</th>
<tr><th>selectionCriterion</th>
<td>A <var>[[SelectionCriterion class|SelectionCriterion]]</var> object, which is a relational expression that is applied to each collection item value to determine whether the value satisfies the expression. This is a required parameter.</td></tr>
<td>A <var>[[SelectionCriterion class|SelectionCriterion]]</var> object, which is a relational expression that is applied to each collection item value to determine whether the value satisfies the expression.  
<p>
For example, <code>GT(income, 0)</code> is the criterion <code>income > 0</code>, where <var>income</var> is a class variable whose value is returned for each item. The items that satisfy the expression populate the subset whose count <var>CountSubset</var> returns.</p>
<p>
For more information about the function in the criterion, see [[SelectionCriterion class#Specifying a SelectionCriterion's parameters|"Specifying a SelectionCriterion's parameters"]].</p></td></tr>
</table>
</table>



Revision as of 21:01, 17 July 2012

Number of items that match some selection criteria (FloatNamedArraylist, NamedArraylist, and UnicodeNamedArraylist classes)

[Introduced in Sirius Mods 7.8]


The CountSubset function returns the number of items in a collection that match a specified selection criterion. It is related to the SubsetNew collection method, which returns not the count but a collection of the matching items for a specified criterion.

Syntax

%number = anyNal:CountSubset( selectionCriterion)

Syntax terms

%number A numeric variable to contain the count of matching items.
anyNal A NamedArraylist, FloatNamedArraylist, or UnicodeNamedArraylist object variable.
selectionCriterion A SelectionCriterion object, which is a relational expression that is applied to each collection item value to determine whether the value satisfies the expression.

For example, GT(income, 0) is the criterion income > 0, where income is a class variable whose value is returned for each item. The items that satisfy the expression populate the subset whose count CountSubset returns.

For more information about the function in the criterion, see "Specifying a SelectionCriterion's parameters".

Usage notes

Examples

See also