boost::shared_ptr< QueueInterface<Task> >&
SystemQueuesManager::operator[](std::string key)
{
    if(queueRegistry.find(key) == queueRegistry.end())
    {
        boost::shared_ptr< QueueInterface<Task> > pointerToInsert
        (new QueueInterface<Task>());
        std::pair
            <
                std::string, boost::shared_ptr
                    <
                        QueueInterface<Task>
                    >
            > pairToInsert(key, pointerToInsert);
        queueRegistry.insert(pairToInsert);
    }
    return queueRegistry[key];
}
Ejemplo n.º 2
0
void graph<vertex_type>::insert(const vertex_type & item, const list< pair<vertex_type, double> > & adjList)
{

	typename unordered_map<vertex_type, vertex<vertex_type>* >::const_iterator lookup = graph_.find(item);


	if( lookup == graph_.end())
	{

		vertex<vertex_type>* newVertex = new vertex<vertex_type>(item);

		for(auto list_entry: adjList)
		{
			lookup = graph_.find(list_entry.first);

			if(lookup == graph_.end())
			{
				vertex<vertex_type>* temp_vertex = new vertex<vertex_type>{list_entry.first};


				pair< vertex_type, vertex<vertex_type>* > pairToInsert(list_entry.first, temp_vertex);
			
				graph_.insert(pairToInsert);


				newVertex->addToList(temp_vertex, list_entry.second);



			}


			else//vertex found in graph
			{

				newVertex->addToList(lookup->second, list_entry.second);

			}
	

		}

		pair<vertex_type, vertex<vertex_type>* > newPair(item, newVertex);

		graph_.insert(newPair);

	}

	else //item is already a vertex in the graph
	{
		vertex<vertex_type>* current_vertex = lookup->second;

		for(auto list_entry: adjList)
		{
			lookup = graph_.find(list_entry.first);

			if(lookup == graph_.end())//not found
			{
				vertex<vertex_type>* temp_vertex = new vertex<vertex_type>{list_entry.first};

				pair< vertex_type, vertex<vertex_type>* > pairToInsert(list_entry.first, temp_vertex);
			
				graph_.insert(pairToInsert);


				current_vertex->addToList(temp_vertex, list_entry.second);

			}


			else//vertex found in graph
			{

				current_vertex->addToList(lookup->second, list_entry.second);

			}
	

		}
		

	}
 

}