Not (SelectionCriterion function): Difference between revisions
mNo edit summary |
m (→Syntax terms) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:SelectionCriterion:Not subtitle}} | {{Template:SelectionCriterion:Not subtitle}} | ||
This shared method creates a new <var>SelectionCriterion</var> object | This [[Notation conventions for methods#Shared members|shared method]] creates a new <var>SelectionCriterion</var> object | ||
that is a logical negation of its <var>SelectionCriterion</var> parameter. | that is a logical negation of its <var>SelectionCriterion</var> parameter. | ||
A <var>Not</var> criterion returns true for a collection item if <var>Not</var>'s | A <var>Not</var> criterion returns true for a collection item if <var>Not</var>'s | ||
Line 21: | Line 21: | ||
<tr><th>%selectionCriterion</th> | <tr><th>%selectionCriterion</th> | ||
<td>A <var>SelectionCriterion</var> object variable to contain the new object instance. </td></tr> | <td>A <var>SelectionCriterion</var> object variable to contain the new object instance. </td></tr> | ||
<tr><th><var>%(SelectionCriterion For</var> | <tr><th nowrap="true"><var>[%(SelectionCriterion For </var>itemType<var>):]</var> | ||
<td>This optional specification of the class in parentheses | <td>This optional specification of the class in parentheses denotes a [[Notation conventions for methods#Constructors|virtual constructor]]. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>SelectionCriterion</var> virtual constructor. </td></tr> | ||
<tr><th>selectionCriterion</th> | <tr><th>selectionCriterion</th> | ||
<td>A SelectionCriterion object. </td></tr> | <td>A SelectionCriterion object. </td></tr> | ||
Line 28: | Line 28: | ||
==Usage Notes== | ==Usage Notes== | ||
<ul> | |||
<li>As described in [[Object variables#Virtual Constructor methods|"Virtual Constructor methods"]], <var>Not</var> can be invoked with | |||
no method object, with an explicit class specification, or with an object variable of the class, | |||
even if that object is <var>Null</var>: | |||
<p class="code">%selCrit = Not(<i>criterion</i>) | |||
The <var>Not</var> constructor is '''never''' necessary, and anything you can | %selCrit = %(SelectionCriterion for float):Not(<i>criterion</i>) | ||
%selCrit = %selCrit:Not(<i>criterion</i>) | |||
</p> | |||
'''Note:''' | |||
As shown in the second of these above, if you explicitly specify the | |||
class name, you must include the item datatype of the collection to be searched, just as on a <var>SelectionCriterion</var> object variable's [[SelectionCriterion class#Declaring a SelectionCriterion object variable|declaration]]. | |||
<li>The <var>Not</var> constructor is '''never''' necessary, and anything you can | |||
do with the <var>Not</var> can be done (probably more clearly) otherwise. | do with the <var>Not</var> can be done (probably more clearly) otherwise. | ||
For example, the following two criteria are identical: | For example, the following two criteria are identical: | ||
Line 51: | Line 63: | ||
Internally, <var>Not</var>s are always converted to the inverse of the parameter criterion. | Internally, <var>Not</var>s are always converted to the inverse of the parameter criterion. | ||
</ul> | |||
==See also== | ==See also== | ||
{{Template:SelectionCriterion:Not footer}} | {{Template:SelectionCriterion:Not footer}} | ||
[[Category:SelectionCriterion methods]] | [[Category:SelectionCriterion methods]] |
Latest revision as of 21:13, 30 November 2011
Matches an item if it does not meet the criterion (SelectionCriterion class)
This shared method creates a new SelectionCriterion object
that is a logical negation of its SelectionCriterion parameter.
A Not criterion returns true for a collection item if Not's
component SelectionCriterion expression is false for the item;
otherwise it returns true.
The collection searching method that makes use of this SelectionCriterion specifies:
- Whether to return the first item or item number or all items that satisfy the selection criterion.
- Where in the collection to begin searching.
Syntax
%selectionCriterion = [%(SelectionCriterion For itemType):]Not( selectionCriterion)
Syntax terms
%selectionCriterion | A SelectionCriterion object variable to contain the new object instance. |
---|---|
[%(SelectionCriterion For itemType):] | This optional specification of the class in parentheses denotes a virtual constructor. See "Usage notes", below, for more information about invoking a SelectionCriterion virtual constructor. |
selectionCriterion | A SelectionCriterion object. |
Usage Notes
- As described in "Virtual Constructor methods", Not can be invoked with
no method object, with an explicit class specification, or with an object variable of the class,
even if that object is Null:
%selCrit = Not(criterion) %selCrit = %(SelectionCriterion for float):Not(criterion) %selCrit = %selCrit:Not(criterion)
Note: As shown in the second of these above, if you explicitly specify the class name, you must include the item datatype of the collection to be searched, just as on a SelectionCriterion object variable's declaration.
- The Not constructor is never necessary, and anything you can
do with the Not can be done (probably more clearly) otherwise.
For example, the following two criteria are identical:
%sel = not(gt(this(90)) %sel = le(this(90))
And the following two criteria are identical:
%sel = not(or(lt(this,70), ge(this,95))) %sel = and(ge(this,70), lt(this,95))
And these criteria are identical:
%sel = not(true) %sel = false
Internally, Nots are always converted to the inverse of the parameter criterion.