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


C++ CWord::size方法代码示例

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


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

示例1: LongestPieceFixedStart

CWord::size_type LongestPieceFixedStart(const CWord& w) {
  CWord::size_type result = 1;
  auto shifted = w;
  shifted.CyclicLeftShift();
  while (shifted != w) {
    result = std::max(result, CommonPrefixLength(w, shifted));
    if (result * 6 >= w.size()) {
      return result;
    }
    shifted.CyclicLeftShift();
  }

  auto inverse = w.Inverse();
  if (LeastCyclicShift(inverse) == LeastCyclicShift(w)) {
    return result;
  }
  result = std::max(result, CommonPrefixLength(w, inverse));
  inverse.CyclicLeftShift();

  while (inverse != w.Inverse()) {
    result = std::max(result, CommonPrefixLength(w, inverse));
    if (result * 6 >= w.size()) {
      return result;
    }
    inverse.CyclicLeftShift();
  }

  return result;
}
开发者ID:dpantele,项目名称:acc,代码行数:29,代码来源:analyze.cpp

示例2: make_tuple

std::tuple<unsigned short, unsigned short, unsigned short> LongestCommonSubwordCyclic(CWord u, CWord v) {
  unsigned short max_common_prefix = 0;
  unsigned short u_max_begin = u.size();
  unsigned short v_max_begin = v.size();

  for (unsigned short current_u_begin = 0; current_u_begin < u.size(); ++current_u_begin) {
    for (unsigned short current_v_begin = 0; current_v_begin < v.size(); ++current_v_begin) {
      auto u_copy = u;
      auto v_copy = v;
      unsigned short current_common_prefix_length = 0;
      while (u_copy.GetFront() == v_copy.GetFront()) {
        ++current_common_prefix_length;
        u_copy.PopFront();
        if (u_copy.Empty()) {
          break;
        }
        v_copy.PopFront();
        if (v_copy.Empty()) {
          break;
        }
      }
      if (current_common_prefix_length > max_common_prefix) {
        u_max_begin = current_u_begin;
        v_max_begin = current_v_begin;
        max_common_prefix = current_common_prefix_length;
      }
      v.CyclicLeftShift();
    }
    u.CyclicLeftShift();
  }

  return std::make_tuple(u_max_begin, v_max_begin, max_common_prefix);
}
开发者ID:dpantele,项目名称:acc,代码行数:33,代码来源:longest_common_subword_cyclic.cpp

示例3: LongestPiece

CWord::size_type LongestPiece(const CWord& w) {
  auto shifted = w;
  CWord::size_type result = 1;
  do {
    result = std::max(result, LongestPieceFixedStart(shifted));
    if (result * 6 >= w.size()) {
      return result;
    }
    shifted.CyclicLeftShift();
  } while (shifted != w);
  return result;
}
开发者ID:dpantele,项目名称:acc,代码行数:12,代码来源:analyze.cpp


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