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


C++ index_map_type::end方法代码示例

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


在下文中一共展示了index_map_type::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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


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