本文整理汇总了C++中boost::unordered_map::count方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::count方法的具体用法?C++ unordered_map::count怎么用?C++ unordered_map::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_map
的用法示例。
在下文中一共展示了unordered_map::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new_kmer
void
checkKmers(DnaString const & kmer,
TVertexDescriptor const & starting_vertex,
TVertexDescriptor const & source_vertex,
TGraph const & graph,
std::vector<VertexLabels> & vertex_vector,
boost::unordered_set<TVertexDescriptor> const & free_nodes,
boost::unordered_map< std::pair<TVertexDescriptor, TVertexDescriptor>, boost::dynamic_bitset<> > & edge_ids,
boost::dynamic_bitset<> const & id_bits,
TKmerMap & kmer_map,
std::size_t const & kmer_size
)
{
if (id_bits.none())
return;
if (length(kmer) == kmer_size)
{
KmerLabels new_kmer_label =
{
starting_vertex,
source_vertex,
id_bits
};
if (kmer_map.count(kmer) == 0)
{
std::vector<KmerLabels> new_vector(1, new_kmer_label);
kmer_map[kmer] = new_vector;
}
else
{
kmer_map[kmer].push_back(new_kmer_label);
}
return;
}
for (Iterator<TGraph, OutEdgeIterator>::Type out_edge_iterator (graph, source_vertex) ; !atEnd(out_edge_iterator) ; ++out_edge_iterator)
{
DnaString new_kmer(kmer);
TVertexDescriptor const & target_vertex = targetVertex(out_edge_iterator);
boost::dynamic_bitset<> new_id_bits(id_bits);
if (free_nodes.count(target_vertex) == 0)
{
seqan::appendValue(new_kmer, vertex_vector[target_vertex].dna);
std::pair<TVertexDescriptor, TVertexDescriptor> edge_pair(source_vertex, target_vertex);
if (edge_ids.count(edge_pair) == 1)
{
new_id_bits = id_bits & edge_ids[edge_pair];
}
}
checkKmers(new_kmer, starting_vertex, target_vertex, graph, vertex_vector, free_nodes, edge_ids, new_id_bits, kmer_map, kmer_size);
}
}
示例2: hopscotch_map_sanity_checks
void hopscotch_map_sanity_checks() {
ASSERT_TRUE(cm2.begin() == cm2.end());
for (size_t i = 0;i < NINS; ++i) {
cm2[17 * i] = i;
um2[17 * i] = i;
}
for (size_t i = 0;i < NINS; ++i) {
assert(cm2[17 * i] == i);
assert(um2[17 * i] == i);
}
assert(cm2.size() == NINS);
assert(um2.size() == NINS);
for (size_t i = 0;i < NINS; i+=2) {
cm2.erase(17*i);
um2.erase(17*i);
}
for (size_t i = 0;i < NINS; i+=2) {
assert(cm2.count(17*i) == i % 2);
assert(um2.count(17*i) == i % 2);
if (cm2.count(17*i)) {
assert(cm2.find(17*i)->second == i);
}
}
assert(cm2.size() == NINS / 2);
assert(um2.size() == NINS / 2);
typedef graphlab::hopscotch_map<uint32_t, uint32_t>::value_type vpair;
{
size_t cnt = 0;
foreach(vpair &v, cm2) {
ASSERT_EQ(v.second, um2[v.first]);
++cnt;
}
ASSERT_EQ(cnt, NINS / 2);
}
示例3: updateDevice
int DeviceCassandraController::updateDevice(
const string &devicename, const string &username,
boost::unordered_map<string, string> ¶ms) {
if (params.size() <= 0)
return 0;
string errorCode = "";
int result;
// Get the current device.
boost::shared_ptr<Device> device = getDevice(devicename, username, errorCode);
if (!errorCode.empty()) {
return boost::lexical_cast<int>(errorCode);
}
// Check if devicename needs to be changed.
if (params.count("new_devicename")) {
// Delete the current device from db.
result = deleteDevice(devicename, username);
if (result != 0) {
return result;
}
}
// Update data in the current device.
if (params.count("new_devicename")) {
device->setDevicename(params["new_devicename"]);
}
if (params.count("type")) {
device->setType(params["type"]);
}
if (params.count("metadata")) {
device->setContentMeta(params["metadata"]);
device->setContentTimestamp(time(NULL));
}
if (params.count("dir_ip")) {
device->setDirIp(params["dir_ip"]);
}
if (params.count("dir_port")) {
unsigned short portValue = -1;
if (!ControllerHelper::isNullOREmptyString(params["dir_port"]))
portValue = boost::lexical_cast<unsigned short>(params["dir_port"]);
device->setDirPort(portValue);
}
if (params.count("ip")) {
device->setIp(params["ip"]);
}
if (params.count("port")) {
unsigned short portValue = -1;
if (!ControllerHelper::isNullOREmptyString(params["port"]))
portValue = boost::lexical_cast<unsigned short>(params["port"]);
device->setPort(portValue);
}
if (params.count("os")) {
device->setOs(params["os"]);
}
if (params.count("description")) {
device->setDescription(params["description"]);
}
if (params.count("public_folder")) {
device->setPublicFolder(params["public_folder"]);
}
if (params.count("private_folder")) {
device->setPrivateFolder(params["private_folder"]);
}
if (params.count("is_indexed")) {
bool is_indexed = false;
if (boost::iequals(params["is_indexed"], "true"))
is_indexed = true;
device->setSearchable(is_indexed);
}
// Update lastseen.
device->setLastSeen(time(NULL));
// Add the new device.
result = addDevice(device);
return result;
}
示例4: buildTable
bool buildTable(Kompex::SQLiteStatement * stmt,
int32_t &name_id,
boost::unordered_map<std::string,int32_t> &table_names,
std::string const &sql_table_name,
std::vector<Tile*> list_tiles,
osmscout::Database &map,
osmscout::TypeSet const &typeSet,
bool allow_duplicate_nodes,
bool allow_duplicate_ways,
bool allow_duplicate_areas)
{
// spec area search parameter
osmscout::AreaSearchParameter area_search_param;
area_search_param.SetUseLowZoomOptimization(false);
// create the sql statement
std::string stmt_insert = "INSERT INTO "+sql_table_name;
stmt_insert +=
"(id,node_offsets,way_offsets,area_offsets) VALUES("
"@id,@node_offsets,@way_offsets,@area_offsets);";
try {
stmt->BeginTransaction();
stmt->Sql(stmt_insert);
}
catch(Kompex::SQLiteException &exception) {
qDebug() << "ERROR: SQLite exception with insert statement:"
<< QString::fromStdString(exception.GetString());
return false;
}
// osmscout may return nearby results again so we make
// sure offsets are only included once if requested
std::set<osmscout::FileOffset> set_node_offsets;
std::set<osmscout::FileOffset> set_way_offsets;
std::set<osmscout::FileOffset> set_area_offsets;
// container for blob memory we delete after
// committing the sql transaction
std::vector<char*> list_blobs;
// keep track of the number of transactions and
// commit after a certain limit
size_t transaction_limit=5000;
size_t transaction_count=0;
for(size_t i=0; i < list_tiles.size(); i++) {
// for each tile
// get objects from osmscout
GeoBoundingBox const &bbox = list_tiles[i]->bbox;
std::vector<osmscout::NodeRef> listNodes;
std::vector<osmscout::WayRef> listWays;
std::vector<osmscout::AreaRef> listAreas;
map.GetObjects(bbox.minLon,bbox.minLat,
bbox.maxLon,bbox.maxLat,
typeSet,
listNodes,
listWays,
listAreas);
// merge all of the object refs into one list
// of MapObjects so its easier to manage
std::vector<MapObject> list_map_objects;
list_map_objects.reserve(listNodes.size()+listWays.size()+listAreas.size());
for(size_t j=0; j < listNodes.size(); j++) {
osmscout::NodeRef &nodeRef = listNodes[j];
if(nodeRef->GetName().empty()) {
continue;
}
if(!allow_duplicate_nodes) {
if(set_node_offsets.count(nodeRef->GetFileOffset()) != 0) {
continue;
}
set_node_offsets.insert(nodeRef->GetFileOffset());
}
MapObject map_object;
map_object.name = nodeRef->GetName();
map_object.offset = nodeRef->GetFileOffset();
map_object.type = osmscout::refNode;
list_map_objects.push_back(map_object);
}
for(size_t j=0; j < listWays.size(); j++) {
osmscout::WayRef &wayRef = listWays[j];
if(wayRef->GetName().empty()) {
continue;
}
if(!allow_duplicate_ways) {
if(set_way_offsets.count(wayRef->GetFileOffset()) != 0) {
continue;
}
set_way_offsets.insert(wayRef->GetFileOffset());
}
MapObject map_object;
map_object.name = wayRef->GetName();
map_object.offset = wayRef->GetFileOffset();
map_object.type = osmscout::refWay;
//.........这里部分代码省略.........
示例5: Dna
void
addExonToGraph (TGraph & g,
unsigned short const & bit_id,
unsigned short const & bit_n,
CharString const & sequence,
std::map<VertexLabels, TVertexDescriptor> & vertex_label_map,
std::vector<VertexLabels> & vertex_vector,
boost::unordered_map<std::pair<TVertexDescriptor, TVertexDescriptor>, boost::dynamic_bitset<> > & edge_ids
)
{
VertexLabels prev_vertex_label = {0, Dna('A')};
TVertexDescriptor prev = vertex_label_map[prev_vertex_label];
for (int pos = 0 ; ; ++pos)
{
if (pos >= (int) length(sequence))
{
VertexLabels final_vertex_label = {
-1, // level
Dna('A'), // Dna, initialized here but we should never use it!
};
TVertexDescriptor target_vertex = vertex_label_map[final_vertex_label];
std::pair<TVertexDescriptor, TVertexDescriptor> my_pair (prev, target_vertex);
addBitsetEdge(edge_ids[my_pair], bit_id, bit_n, edge_ids.count(my_pair));
if (!findEdge(g, prev, target_vertex))
addEdge(g, prev, target_vertex);
break;
}
if (sequence[pos] == '-')
continue;
VertexLabels new_vertex_label =
{
pos+1, // level
Dna(sequence[pos]), // dna
};
TVertexDescriptor target_vertex;
if (vertex_label_map.count(new_vertex_label) == 1)
{
target_vertex = vertex_label_map[new_vertex_label];
std::pair<TVertexDescriptor, TVertexDescriptor> my_pair (prev, target_vertex);
addBitsetEdge(edge_ids[my_pair], bit_id, bit_n, edge_ids.count(my_pair));
if (!findEdge(g, prev, target_vertex))
addEdge(g, prev, target_vertex);
}
else
{
target_vertex = addVertex(g);
std::pair<TVertexDescriptor, TVertexDescriptor> my_pair (prev, target_vertex);
addBitsetEdge(edge_ids[my_pair], bit_id, bit_n, edge_ids.count(my_pair));
addEdge(g, prev, target_vertex);
vertex_label_map[new_vertex_label] = target_vertex;
vertex_vector.push_back(new_vertex_label);
}
prev = target_vertex;
}
}