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


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

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


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

示例1: 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


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