Class Logic
This sealed class exposes methods that encapsulate many common, tricky loop state tests.
Since static classes are implicitly sealed, this class cannot be inherited.
Inheritance
Namespace: WizardWrx
Assembly: WizardWrx.Core.dll
Syntax
public static class Logic : object
Methods
| Improve this Doc View SourceIsFirstForIteration(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its first iteration.
Declaration
public static bool IsFirstForIteration(int pintLoopIndex, int pintInitialValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintInitialValue | Specify the integer initial value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index of a FOR loop is at its initial value, indicating the first iteration of the loop. |
See Also
IsLastForIterationEQ(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its last iteration, given that the limit criterion is pintLoopIndex is greater than pintLimit.
Declaration
public static bool IsLastForIterationEQ(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the next increment of the loop index would set one less than pintLimit, stopping the loop without another iteration. |
See Also
IsLastForIterationGE(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its last iteration, given that the limit criterion is pintLoopIndex is greater than or equal to pintLimit.
Declaration
public static bool IsLastForIterationGE(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the next increment of the loop index would set equal to pintLimit, stopping the loop without another iteration. |
See Also
IsLastForIterationGT(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its last iteration, given that the limit criterion is pintLoopIndex is greater than pintLimit.
Declaration
public static bool IsLastForIterationGT(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the next increment of the loop index would set one less than pintLimit, stopping the loop without another iteration. |
See Also
IsLastForIterationLE(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its last iteration, given that the limit criterion is pintLoopIndex is less than or equal to pintLimit.
Declaration
public static bool IsLastForIterationLE(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the next increment of the loop index would set it equal to pintLimit, stopping the loop without another iteration. |
See Also
IsLastForIterationLT(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on its last iteration, given that the limit criterion is pintLoopIndex is less than pintLimit.
Declaration
public static bool IsLastForIterationLT(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the next increment of the loop index would set it equal to pintLimit, stopping the loop without another iteration. |
See Also
IsNextForIteration(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex is on a subsequent iteration.
Declaration
public static bool IsNextForIteration(int pintLoopIndex, int pintInitialValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintInitialValue | Specify the integer initial value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index of a FOR loop has passed its initial value, indicating that it is on a subsequent iteration of the loop. |
See Also
MoreForIterationsToComeEQ(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex has one or more iteration to go, given that the limit criterion is pintLoopIndex is equal to pintLimit.
Declaration
public static bool MoreForIterationsToComeEQ(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index and limit indicate that one or more iterations remain. |
See Also
MoreForIterationsToComeGE(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex has one or more iteration to go, given that the limit criterion is pintLoopIndex is greater than or equal to pintLimit.
Declaration
public static bool MoreForIterationsToComeGE(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index and limit indicate that one or more iterations remain. |
See Also
MoreForIterationsToComeGT(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex has one or more iteration to go, given that the limit criterion is pintLoopIndex is greater than pintLimit.
Declaration
public static bool MoreForIterationsToComeGT(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index and limit indicate that one or more iterations remain. |
See Also
MoreForIterationsToComeLE(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex has one or more iteration to go, given that the limit criterion is pintLoopIndex is less than or equal to pintLimit.
Declaration
public static bool MoreForIterationsToComeLE(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index and limit indicate that one or more iterations remain. |
Remarks
Sometimes, it is more sensible to test whether there are iterations remaining.
See Also
MoreForIterationsToComeLT(Int32, Int32)
Return TRUE if the FOR loop driven by pintLoopIndex has one or more iteration to go, given that the limit criterion is pintLoopIndex is less than pintLimit.
Declaration
public static bool MoreForIterationsToComeLT(int pintLoopIndex, int pintLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintLoopIndex | Specify the integer loop index. |
System.Int32 | pintLimit | Specify the integer limit value. |
Returns
Type | Description |
---|---|
System.Boolean | This function returns TRUE if the index and limit indicate that one or more iterations remain. |
Remarks
Sometimes, it is more sensible to test whether there are iterations remaining.
See Also
Unless(Boolean)
Return the inverse of the truth value of an expression.
Declaration
public static bool Unless(bool pfUnlessWhat)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | pfUnlessWhat | Specify the expression to invert. |
Returns
Type | Description |
---|---|
System.Boolean | Return TRUE if pfUnlessWhat is FALSE, and vice vers. |
Remarks
I shamelessly borrowed this idiom from Perl, with full credit to Larry Wall, and implemented it as a macro for the C and C++ source code preprocessors about a decade ago. I don't know why it's taken me this long to realize that it is equally easy to implement in C#, and the implementation is sufficiently small that the code optimizer will almost certainly inline it, so that its performance impact is equivalent to the C/C++ macro.
The C# implementation is not quite as neat as the C/C++ macro.