本文整理汇总了C++中std::unordered_multimap::size方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_multimap::size方法的具体用法?C++ unordered_multimap::size怎么用?C++ unordered_multimap::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unordered_multimap
的用法示例。
在下文中一共展示了unordered_multimap::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_keypoint_strokes
PyArrayObject* get_keypoint_strokes(int keypointId, int instance)
{
if(keypointsPixels.size() > 0)
{
std::pair <std::unordered_multimap<int,std::pair<int, int> >::iterator, std::unordered_multimap<int,std::pair<int, int>>::iterator> ret;
ret = keypointsPixels.equal_range(keypoints[keypointId].class_id);
npy_intp size_pts[2];
size_pts[0] = std::distance(ret.first, ret.second);
size_pts[1] = 2;
PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
int strokesCount = 0;
for (std::unordered_multimap<int,std::pair<int, int> >::iterator it=ret.first; it!=ret.second; it++)
{
char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.first));
ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.second));
strokesCount++;
}
return out;
}
std::vector<std::vector<cv::Ptr<StrokeDir> > >& strokes = instances[instance].segmenter->keypointStrokes[keypointId];
npy_intp size_pts[2];
int strokesCount = 0;
for( size_t i = 0; i < strokes.size(); i++ )
{
strokesCount += strokes[i].size();
}
size_pts[0] = strokesCount;
size_pts[1] = 4;
PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
strokesCount = 0;
for( size_t i = 0; i < strokes.size(); i++ )
{
for( size_t j = 0; j < strokes[i].size(); j++ )
{
char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.x));
ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.y));
ptr = (char*) PyArray_GETPTR2(out, strokesCount, 2);
PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.x));
ptr = (char*) PyArray_GETPTR2(out, strokesCount, 3);
PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.y));
strokesCount++;
}
}
return out;
}
示例2: filesIncomingToRawFilesInfo
void filesIncomingToRawFilesInfo(Utils::raw_fileinfo *raw[], const std::unordered_multimap<std::string, HttpServer::FileIncoming> &map)
{
if (raw && map.size() )
{
raw_fileinfo *arr = new raw_fileinfo[map.size()];
*raw = arr;
size_t i = 0;
for (auto it = map.cbegin(); map.cend() != it; ++it, ++i)
{
arr[i].key = stlStringToPChar(it->first);
const HttpServer::FileIncoming &file = it->second;
arr[i].file_name = stlStringToPChar(file.getName() );
arr[i].file_type = stlStringToPChar(file.getType() );
arr[i].file_size = file.getSize();
}
}
}
示例3: packFilesIncoming
void packFilesIncoming(
std::vector<char> &buf,
const std::unordered_multimap<std::string, Transfer::FileIncoming> &map
) {
packNumber(buf, map.size() );
for (auto it = map.cbegin(); map.cend() != it; ++it) {
packString(buf, it->first);
const Transfer::FileIncoming &file = it->second;
packString(buf, file.getTmpName() );
packString(buf, file.getName() );
packString(buf, file.getType() );
packNumber(buf, file.getSize() );
}
}
示例4: PrettyPrint
inline std::string PrettyPrint(const std::unordered_multimap<A, B, Hash, Predicate, Allocator>& maptoprint, const bool add_delimiters=false, const std::string& separator=", ")
{
std::ostringstream strm;
if (maptoprint.size() > 0)
{
if (add_delimiters)
{
strm << "{";
typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
{
std::pair<A, B> cur_pair(itr->first, itr->second);
if (itr != maptoprint.begin())
{
strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
}
else
{
strm << PrettyPrint(cur_pair, add_delimiters, separator);
}
}
strm << "}";
}
else
{
typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
{
std::pair<A, B> cur_pair(itr->first, itr->second);
if (itr != maptoprint.begin())
{
strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
}
else
{
strm << PrettyPrint(cur_pair, add_delimiters, separator);
}
}
}
}
return strm.str();
}
示例5: operator
void operator()(msgpack::object::with_zone& o, const std::unordered_multimap<K, V, Hash, Compare, Alloc>& v) const {
o.type = msgpack::type::MAP;
if(v.empty()) {
o.via.map.ptr = nullptr;
o.via.map.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
msgpack::object_kv* const pend = p + size;
o.via.map.ptr = p;
o.via.map.size = size;
typename std::unordered_multimap<K, V, Hash, Compare, Alloc>::const_iterator it(v.begin());
do {
p->key = msgpack::object(it->first, o.zone);
p->val = msgpack::object(it->second, o.zone);
++p;
++it;
} while(p < pend);
}
}