CountSubset (GenericNamedArraylist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:


The <var>CountSubset</var> function returns the number of items in a collection that match a
The <var>CountSubset</var> function returns the number of items in a collection that match a
specified selection criterion. It is related to the <var>[[SubsetNew (GenericNamedArraylist function)|SubsetNew]]</var> collection method, which returns not the count but a collection of the matching items for a specified criterion.
specified selection criterion. It is related to the <var>[[SubsetNew (NamedArraylist function)|SubsetNew]]</var> collection method, which returns not the count but a collection of the matching items for a specified criterion.


==Syntax==
==Syntax==
Line 25: Line 25:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>A <var>CountSubset</var> call with a particular selection criterion is equivalent to a count of the items in the subset returned by the <var>[[SubsetNew (GenericNamedArraylist function)|SubsetNew]]</var> method with that criterion.  
<li>A <var>CountSubset</var> call with a particular selection criterion is equivalent to a count of the items in the subset returned by the <var>SubsetNew</var> method with that criterion.  
</ul>
</ul>


==Examples==
==Examples==
For the collection whose items are the odd integers between 0 and 10, and the selection criterion <code>LT(this, 9))</code>, <var>CountSubset</var> returns <code>4</code>.


==See also==
==See also==
{{Template:GenericNamedArraylist:CountSubset footer}}
{{Template:GenericNamedArraylist:CountSubset footer}}

Latest revision as of 20:16, 2 September 2014

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

  • A CountSubset call with a particular selection criterion is equivalent to a count of the items in the subset returned by the SubsetNew method with that criterion.

Examples

For the collection whose items are the odd integers between 0 and 10, and the selection criterion LT(this, 9)), CountSubset returns 4.

See also