当前位置: 首页>>代码示例>>C++>>正文


C++ ANode::toStringMe方法代码示例

本文整理汇总了C++中ANode::toStringMe方法的典型用法代码示例。如果您正苦于以下问题:C++ ANode::toStringMe方法的具体用法?C++ ANode::toStringMe怎么用?C++ ANode::toStringMe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ANode的用法示例。


在下文中一共展示了ANode::toStringMe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cmpByDynInfoSpecial

int
ANodeSortedIterator::cmpByDynInfo(const void* a, const void* b)
{
  ANode* x = (*(ANode**)a);
  ANode* y = (*(ANode**)b);

  // 0. test for equality
  if (x == y) {
    return 0;
  }

  // INVARIANT: x != y, so never return 0

  ADynNode* x_dyn = dynamic_cast<ADynNode*>(x);
  ADynNode* y_dyn = dynamic_cast<ADynNode*>(y);

  // 1. distinguish by dynamic info
  if (x_dyn && y_dyn) {
    return cmpByDynInfoSpecial(x_dyn, y_dyn);
  }

  // 2. distinguish by structure ids
  uint x_id = x->structureId();
  uint y_id = y->structureId();
  if (x_id != Prof::Struct::ANode::Id_NULL
      && y_id != Prof::Struct::ANode::Id_NULL) {
    int cmp_sid = cmp(x_id, y_id);
    if (cmp_sid != 0) {
      return cmp_sid;
    }
  }

  // 3. distinguish by type
  int cmp_ty = (int)x->type() - (int)y->type();
  if (cmp_ty != 0) {
    return cmp_ty;
  }


#if 1
  // 4. distinguish by id
  int cmp_id = (int)x->id() - (int)y->id();
  if (cmp_id != 0) {
    return cmp_id;
  }
#endif

  // *. Could compare childCount() and other aspects of children.
  DIAG_Die("Prof::CCT::ANodeSortedIterator::cmpByDynInfo: cannot compare:"
	   << "\n\tx: " << x->toStringMe(Prof::CCT::Tree::OFlg_Debug)
	   << "\n\ty: " << y->toStringMe(Prof::CCT::Tree::OFlg_Debug));
}
开发者ID:HPCToolkit,项目名称:hpctoolkit,代码行数:52,代码来源:CCT-TreeIterator.cpp

示例2: if

int
ANodeSortedIterator::cmpByStructureInfo(const void* a, const void* b)
{
  ANode* x = (*(ANode**)a);
  ANode* y = (*(ANode**)b);

  if (x && y) {
    // 0. test for equality
    if (x == y) {
      return 0;
    }

    // INVARIANT: x != y, so never return 0
    
    // 1. distinguish by structure ids
    uint x_id = x->structureId();
    uint y_id = y->structureId();
    int cmp_sid = cmp(x_id, y_id);
    if (cmp_sid != 0) {
      return cmp_sid;
    }

    // 2. distinguish by types
    int cmp_ty = (int)x->type() - (int)y->type();
    if (cmp_ty != 0) {
      return cmp_ty;
    }

    // 3. distinguish by dynamic info (unnormalized CCTs)
    //    (for determinism, ensure x and y are both ADynNodes)
    ADynNode* x_dyn = dynamic_cast<ADynNode*>(x);
    ADynNode* y_dyn = dynamic_cast<ADynNode*>(y);
    if (x_dyn && y_dyn) {
      int cmp_dyn = cmpByDynInfoSpecial(x_dyn, y_dyn);
      if (cmp_dyn != 0) {
	return cmp_dyn;
      }
    }
    
    
    // 5. distinguish by id
    int cmp_id = (int)x->id() - (int)y->id();
    if (cmp_id != 0) {
      return cmp_id;
    }

    // 4. distinguish by tree context
    ANode* x_parent = x->parent();
    ANode* y_parent = y->parent();
    if (x_parent != y_parent) {
      int cmp_ctxt = cmpByStructureInfo(&x_parent, &y_parent);
      if (cmp_ctxt != 0) {
	return cmp_ctxt;
      }
    }
    // *. Could compare childCount() and other aspects of children.
    DIAG_Die("Prof::CCT::ANodeSortedIterator::cmpByStructureInfo: cannot compare:"
		<< "\n\tx: " << x->toStringMe(Prof::CCT::Tree::OFlg_Debug)
		<< "\n\ty: " << y->toStringMe(Prof::CCT::Tree::OFlg_Debug));
    return 0;
  }
  else if (x) {
    return 1; // x > y=NULL (only used for recursive case)
  }
  else if (y) {
    return -1; // x=NULL < y (only used for recursive case)
  }
  else {
    DIAG_Die(DIAG_UnexpectedInput);
  }
}
开发者ID:HPCToolkit,项目名称:hpctoolkit,代码行数:71,代码来源:CCT-TreeIterator.cpp


注:本文中的ANode::toStringMe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。