• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ index_map_type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update

 /** 
  * Updates the priority associated with a item in the queue. This
  * function fails if the item is not already present.
 */
 void update(T item, Priority priority) {
   // Verify that the item is currently in the queue
   typename index_map_type::const_iterator iter = index_map.find(item);
   assert(iter != index_map.end());
   // If it is already present update the priority
   size_t i = iter->second;
   heap[i].second = priority;
   while ((i > 1) && (priority_at(parent(i)) < priority)) {
     swap(i, parent(i));
     i = parent(i);
   }
   heapify(i);
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:17,代码来源:mutable_queue.hpp


示例2: remove

 //! Remove an item from the queue
 bool remove(T item) {
   // Ensure that the element is in the queue
   typename index_map_type::iterator iter = index_map.find(item);
   // only if the element is present in the first place do we need
   // remove it
   if(iter != index_map.end()) {
     size_t i = iter->second;
     swap(i, size());
     heap.pop_back();
     heapify(i);
     // erase the element from the index map
     index_map.erase(iter);
     return true;
   } 
   return false;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:17,代码来源:mutable_queue.hpp


示例3: insert_cumulative

 /**
  * If item is already in the queue, sets its priority to the sum
  * of the old priority and the new one. If the item is not in the queue,
  * adds it to the queue.
  *
  * returns true if the item was already present
  */
 bool insert_cumulative(T item, Priority priority) {
   // determine if the item is already in the queue
   typename index_map_type::const_iterator iter = index_map.find(item);
   if(iter != index_map.end()) { // already present
     // If it is already present update the priority
     size_t i = iter->second;
     heap[i].second = priority + heap[i].second;
     // If the priority went up move the priority until its greater
     // than its parent
     while ((i > 1) && (priority_at(parent(i)) <= priority)) {
       swap(i, parent(i));
       i = parent(i);
     } 
     // Trickle down if necessary
     heapify(i);  // This should not be necessary
     return false;
   } else { // not already present so simply add
     push(item, priority);
     return true;
   }
 } // end of insert cumulative
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:28,代码来源:mutable_queue.hpp


示例4: vector_property_map

 vector_property_map(unsigned inital_size, 
                     const index_map_type& index = index_map_type())
   : inherited(index.process_group(), index.global(),
               local_iterator_map(inital_size, index.base())) { }
开发者ID:AsherBond,项目名称:PDAL,代码行数:4,代码来源:vector_property_map.hpp


示例5: get

 //! Returns the weight associated with a key
 Priority get(T item) const {
   typename index_map_type::const_iterator iter = index_map.find(item);
   assert(iter != index_map.end());
   size_t i = iter->second;
   return heap[i].second;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:7,代码来源:mutable_queue.hpp


示例6: iterator_property_map

 iterator_property_map(RandomAccessIterator cc, const index_map_type& id)
   : inherited(id.process_group(), id.global(), 
               local_iterator_map(cc, id.base())) { }
开发者ID:imos,项目名称:icfpc2015,代码行数:3,代码来源:parallel_property_maps.hpp


示例7: two_bit_color_map

two_bit_color_map(std::size_t inital_size, 
                  const index_map_type& index = index_map_type())
  : inherited(index.process_group(),  index.global(),
              local_map(inital_size, index.base())) { }
开发者ID:00liujj,项目名称:dealii,代码行数:4,代码来源:two_bit_color_map.hpp


示例8: pop

 /**
  * Removes the item with maximum priority from the queue, and
  * returns it with its priority.
  */
 std::pair<T, Priority> pop() {
   assert(!empty());
   heap_element top = heap[1];
   swap(1, size());
   heap.pop_back();
   heapify(1);
   index_map.erase(top.first);
   return top;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:13,代码来源:mutable_queue.hpp


示例9: clear

 //! Clears all the values (equivalent to stl clear)
 void clear() {
   heap.clear();
   heap.push_back(std::make_pair(T(), Priority()));
   index_map.clear();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:6,代码来源:mutable_queue.hpp


示例10: contains

 //! Returns true if the queue contains the given value
 bool contains(const T& item) const {
   return index_map.count(item) > 0;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:4,代码来源:mutable_queue.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ init_singleton类代码示例发布时间:2022-05-31
下一篇:
C++ incoming_message类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap