本文整理汇总了C++中EMap::size方法的典型用法代码示例。如果您正苦于以下问题:C++ EMap::size方法的具体用法?C++ EMap::size怎么用?C++ EMap::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMap
的用法示例。
在下文中一共展示了EMap::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeUnique
//----------------------------------------------------------------------------
void ExtractCurveTris::MakeUnique (std::vector<Vector2f>& vertices,
std::vector<EdgeKey>& edges)
{
int numVertices = (int)vertices.size();
if (numVertices == 0)
{
return;
}
// Use maps to generate unique storage.
typedef std::map<Vector2f, int> VMap;
typedef std::map<Vector2f, int>::iterator VIterator;
VMap vertexMap;
for (int v = 0, nextVertex = 0; v < numVertices; ++v)
{
std::pair<VIterator, bool> result = vertexMap.insert(
std::make_pair(vertices[v], nextVertex));
if (result.second == true)
{
++nextVertex;
}
}
typedef std::map<EdgeKey, int> EMap;
typedef std::map<EdgeKey, int>::iterator EIterator;
EMap* edgeMap = 0;
int e;
VIterator vIter;
int numEdges = (int)edges.size();
if (numEdges)
{
edgeMap = new0 EMap();
int nextEdge = 0;
for (e = 0; e < numEdges; ++e)
{
// Replace old vertex indices by new ones.
vIter = vertexMap.find(vertices[edges[e].V[0]]);
assertion(vIter != vertexMap.end(), "Unexpected condition\n");
edges[e].V[0] = vIter->second;
vIter = vertexMap.find(vertices[edges[e].V[1]]);
assertion(vIter != vertexMap.end(), "Unexpected condition\n");
edges[e].V[1] = vIter->second;
// Keep only unique edges.
std::pair<EIterator, bool> result = edgeMap->insert(
std::make_pair(edges[e], nextEdge));
if (result.second == true)
{
++nextEdge;
}
}
}
// Pack the vertices into an array.
numVertices = (int)vertexMap.size();
vertices.resize(numVertices);
for (vIter = vertexMap.begin(); vIter != vertexMap.end(); ++vIter)
{
vertices[vIter->second] = vIter->first;
}
// Pack the edges into an array.
if (numEdges > 0)
{
numEdges = (int)edgeMap->size();
edges.resize(numEdges);
EIterator eIter;
for (eIter = edgeMap->begin(); eIter != edgeMap->end(); ++eIter)
{
edges[eIter->second] = eIter->first;
}
delete0(edgeMap);
}
else
{
edges.clear();
}
}