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


C++ c4_View::SortOn方法代码示例

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


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

示例1: while

c4_JoinViewer::c4_JoinViewer(c4_Sequence &seq_, const c4_View &keys_, const
  c4_View &view_, bool outer_): _parent(&seq_), _argView(view_.SortOn(keys_)) {
  // why not in GetTemplate, since we don't need to know this...
  _template = _parent.Clone();
  for (int l = 0; l < _argView.NumProperties(); ++l)
    _template.AddProperty(_argView.NthProperty(l));

  c4_View sorted = _parent.SortOn(keys_).Project(keys_);
  c4_View temp = _argView.Project(keys_);

  _base.SetSize(0, 5);
  _offset.SetSize(0, 5);

  int j = 0, n = 0;

  for (int i = 0; i < sorted.GetSize(); ++i) {
    int orig = _parent.GetIndexOf(sorted[i]);
    d4_assert(orig >= 0);

    if (i > 0 && sorted[i] == sorted[i - 1]) {
      // if last key was same, repeat the same join
      int last = _offset.GetSize() - n;
      for (int k = 0; k < n; ++k) {
        _base.Add(orig);
        _offset.Add(_offset.GetAt(last + k));
      }
    } else
     { // no, this is a new combination
      bool match = false;

      // advance until the temp view entry is >= this sorted entry
      while (j < temp.GetSize())
      if (sorted[i] <= temp[j]) {
        match = sorted[i] == temp[j];
        break;
      } else
        ++j;

      n = 0;

      if (match) {
        do {
          _base.Add(orig);
          _offset.Add(j);
          ++n;
        } while (++j < temp.GetSize() && temp[j] == temp[j - 1]);
      } else if (outer_) {
        // no match, add an entry anyway if this is an outer join
        _base.Add(orig);
        _offset.Add(~(t4_i32)0); // special null entry
        ++n;
      }
    }
  }
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:55,代码来源:custom.cpp

示例2: A

 v1.Add(p1[345] + p2["four"]);
 v1.Add(p1[234] + p2["five"]);
 v1.Add(p1[123] + p2["six"]);
 c4_View v2 = v1.Sort();
 A(v2.GetSize() == 6);
 A(p1(v2[0]) == 111);
 A(p1(v2[1]) == 123);
 A(p1(v2[2]) == 222);
 A(p1(v2[3]) == 234);
 A(p1(v2[4]) == 333);
 A(p1(v2[5]) == 345);
 A(v2.Search(p1[123]) == 1);
 A(v2.Search(p1[100]) == 0);
 A(v2.Search(p1[200]) == 2);
 A(v2.Search(p1[400]) == 6);
 c4_View v3 = v1.SortOn(p2);
 A(v3.GetSize() == 6);
 A(p1(v3[0]) == 234);
 A(p1(v3[1]) == 345);
 A(p1(v3[2]) == 111);
 A(p1(v3[3]) == 123);
 A(p1(v3[4]) == 333);
 A(p1(v3[5]) == 222);
 A(v3.Search(p2["six"]) == 3);
 A(v3.Search(p2["aha"]) == 0);
 A(v3.Search(p2["gee"]) == 2);
 A(v3.Search(p2["wow"]) == 6);
 c4_View v4 = v1.SortOnReverse(p2, p2);
 A(v4.GetSize() == 6);
 A(p1(v4[0]) == 222);
 A(p1(v4[1]) == 333);
开发者ID:OpenSourceInternetV2,项目名称:mettanode,代码行数:31,代码来源:tbasic2.cpp


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