.. _stdlib_cmp: ========================= Comparisons and orderings ========================= .. das:module:: cmp The CMP module holds comparisons: it writes lexicographic orderings from a list of keys. The ``[ordered]`` structure annotation generates the structure's ``operator <``, so ``sort`` and everything else that compares with ``<`` orders it by default; the ``cmp_by`` call macro writes a comparator block for one call, with each key an expression over ``_``, the element, and a leading ``-`` for descending order. All functions and symbols are in "cmp" module, use require to get access to it. .. code-block:: das require daslib/cmp +++++++++++ Call macros +++++++++++ .. _call-macro-cmp-cmp_by: .. das:attribute:: cmp_by Function annotation cmp_by ++++++++++++++++ Structure macros ++++++++++++++++ .. _handle-cmp-ordered: .. das:attribute:: ordered Structure annotation ordered +++++++ Classes +++++++ .. _struct-cmp-OrderedMacro: .. das:attribute:: OrderedMacro : AstStructureAnnotation class OrderedMacro .. _function-cmp_OrderedMacro_rq_apply_OrderedMacro_StructurePtr_ModuleGroup_AnnotationArgumentList_das_string_0x72: .. das:function:: OrderedMacro.apply(st: StructurePtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool def apply : function<(var self:ast::AstStructureAnnotation;var st:ast_core::Structure? aka StructurePtr -const;var group:rtti_core::ModuleGroup -const;var args:rtti_core::AnnotationArgumentList -const;var errors:$::das_string -const):bool> :Arguments: * **st** : :ref:`StructurePtr ` * **group** : :ref:`ModuleGroup ` * **args** : :ref:`AnnotationArgumentList ` * **errors** : :ref:`das_string ` .. _struct-cmp-CmpByMacro: .. das:attribute:: CmpByMacro : AstCallMacro class CmpByMacro .. _function-cmp_CmpByMacro_rq_visit_CmpByMacro_ProgramPtr_Module_q__ExprCallMacro_q__0xb7: .. das:function:: CmpByMacro.visit(prog: ProgramPtr; mod: Module?; expr: ExprCallMacro?) : ExpressionPtr def visit : function<(var self:ast::AstCallMacro;prog:smart_ptr aka ProgramPtr const;mod:rtti_core::Module? const;expr:ast_core::ExprCallMacro? const):ast_core::Expression? aka ExpressionPtr> :Arguments: * **prog** : :ref:`ProgramPtr ` * **mod** : :ref:`Module `? * **expr** : :ref:`ExprCallMacro `? .. _function-cmp_CmpByMacro_rq_canVisitArgument_CmpByMacro_ExprCallMacro_q__int_0xb6: .. das:function:: CmpByMacro.canVisitArgument(expr: ExprCallMacro?; argIndex: int) : bool def canVisitArgument : function<(var self:ast::AstCallMacro;expr:ast_core::ExprCallMacro? const;argIndex:int const):bool> :Arguments: * **expr** : :ref:`ExprCallMacro `? * **argIndex** : int