compareTo
Short summary
This method compares a foreign object with the own one, this is needed for sort orders. The abstract class evaluates every object that is NULL as greater, and all other objects as equal.
Return: SMALLER: THIS precedes in order,
EQUAL: THIS and object at the same position in order,
GREATER: THIS is after in order.
Checkout :CNM_CollectionInterfaces.ComparationResult.
- Return type: CNM_ReturnTypes.ComparationResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| object | CNM_CollectionInterfaces.CNM_AbstractObject.IObject | the object to be compared to | input |
Code
Declaration
METHOD compareTo :CNM_ReturnTypes.ComparationResult
VAR_INPUT
(*the object to be compared to*)
object :CNM_CollectionInterfaces.CNM_AbstractObject.IObject;
END_VAR
VAR
collection :CNM_CollectionInterfaces.ICollection;
END_VAR
Implementation
IF (THIS^.isObjectNull(object)) THEN
compareTo := CNM_ReturnTypes.ComparationResult.GREATER;
ELSE
compareTo := CNM_ReturnTypes.ComparationResult.EQUAL;
IF(__QUERYINTERFACE(object, collection)) THEN
IF(collection.size < THIS^.size) THEN
compareTo := CNM_ReturnTypes.ComparationResult.GREATER;
ELSIF(collection.size > THIS^.size) THEN
compareTo := CNM_ReturnTypes.ComparationResult.SMALLER;
END_IF
END_IF
END_IF