本文整理汇总了C++中AssociativeContainer::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ AssociativeContainer::insert方法的具体用法?C++ AssociativeContainer::insert怎么用?C++ AssociativeContainer::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssociativeContainer
的用法示例。
在下文中一共展示了AssociativeContainer::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: breadth_first_search
static void breadth_first_search(const GraphType& graph,
const VertexIndexType& source,
const int& k_steps,
AssociativeContainer& visited_vertices) {
/* CHECK: AssociativeContainer::value_type == VertexIndexType */
std::queue<VertexIndexType> even_epoch_queue;
std::queue<VertexIndexType> odd_epoch_queue;
std::queue<VertexIndexType>& current_queue = even_epoch_queue;
std::queue<VertexIndexType>& next_queue = odd_epoch_queue;
current_queue.push (source);
int step_number = 0;
while (step_number<k_steps) {
while (!current_queue.empty ()) {
const int vertex = current_queue.front ();
current_queue.pop ();
visited_vertices.insert (vertex);
for (int target_index=graph.begin(vertex);
target_index<graph.end(vertex);
++target_index) {
const int target = graph.get_target (target_index);
if (visited_vertices.end()==visited_vertices.find (target)) {
next_queue.push (target);
}
}
}
++step_number;
current_queue = (step_number&0x10)?even_epoch_queue:odd_epoch_queue;
next_queue = (step_number&0x01)?even_epoch_queue:odd_epoch_queue;
}
}
示例2: make_pair
std::pair<typename AssociativeContainer::iterator, bool>
push_dispatch(AssociativeContainer& c, const T& v,
multiple_associative_container_tag)
{
return std::make_pair(c.insert(v), true);
}
示例3:
std::pair<typename AssociativeContainer::iterator, bool>
push_dispatch(AssociativeContainer& c, const T& v,
unique_associative_container_tag)
{
return c.insert(v);
}