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


C++ Item::GetIndex方法代码示例

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


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

示例1: Pop

void VariableWindowDataSet::Pop() {
  auto& transaction = Front();
  if (first_chunk_start_offset + 1 < chunk_size) {
    // Update the inverted index to clear the bits set corresponding to
    // the items in this transaction.
    auto offset = transaction.id - first_chunk_start_tid;
    ASSERT(offset == first_chunk_start_offset);
    ASSERT((offset / chunk_size) == 0); // Should be first chunk.
    auto bit_num = offset % chunk_size;

    for (uint32_t i = 0; i < transaction.items.size(); i++) {
      Item item = transaction.items[i];
      // Assert that the bit was actually set first!
      ASSERT(index[item.GetIndex()][0][bit_num] == true);
      index[item.GetIndex()][0].set(bit_num, false);
    }
    first_chunk_start_offset++;
  } else {
    // We're removing the last transaction in the first chunk/bitset. We
    // must drop every tidlist's first chunk.
    for (uint32_t i = 0; i < index.size(); i++) {
      TidList& tidlist = index[i];
      if (tidlist.size() > 0) {
        // Some tid lists can be empty if the corresponding item only appeared
        // in blocks that have already been purged.
        tidlist.erase(tidlist.begin(), tidlist.begin() + 1);
      }
    }
    first_chunk_start_offset = 0;
    first_chunk_start_tid += chunk_size;
  }
  transactions.pop_front();
}
开发者ID:cpearce,项目名称:HARM,代码行数:33,代码来源:VariableWindowDataSet.cpp

示例2: Count

int VariableWindowDataSet::Count(const ItemSet& aItemSet) const {
  auto& items = aItemSet.mItems;

  // Find item with the shortest tidlist.
  auto itr = items.begin();
  Item smallest_item = *itr;
  // Note: We do not increment iterator, so we do the existence in the
  // loop check below.
  for (; itr != items.end(); itr++) {
    Item item = *itr;
    if (item.GetIndex() >= index.size()) {
      // Item does not exist in itemset, so it will have 0 count.
      return 0;
    }
    if (index[item.GetIndex()].size() < index[smallest_item.GetIndex()].size()) {
      smallest_item = item;
    }
  }

  // AND the shortest tidlist with all other item's tidlists, and count that.
  size_t count = 0;
  const TidList& shortest = index[smallest_item.GetIndex()];
  for (uint32_t i = 0; i < shortest.size(); i++) {
    bitset<chunk_size> b(shortest[i]);
    if (b.none()) {
      // No bits set in this chunk, no point iterating over other chunks, as
      // the result will be 0 when we AND with them.
      continue;
    }
    for (auto itr = items.begin(); itr != items.end(); itr++) {
      if (*itr == smallest_item) {
        continue;
      }
      const TidList& other = index[itr->GetIndex()];
      if (i < other.size()) {
        b &= other[i];
      }
    }
    count += b.count();
  }
  return (int)count;
}
开发者ID:cpearce,项目名称:HARM,代码行数:42,代码来源:VariableWindowDataSet.cpp


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