本文整理汇总了C++中TupleList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ TupleList::push_back方法的具体用法?C++ TupleList::push_back怎么用?C++ TupleList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TupleList
的用法示例。
在下文中一共展示了TupleList::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBigramCount
TupleList MBConnection::getBigramCount(const std::string& word1, const std::string& word2)
{
MYSQL_BIND param[2];
memset(param, 0, 2 * sizeof(MYSQL_BIND));
setBindValue<0>(param, word1);
setBindValue<1>(param, word2);
long nameId;
long lineCount;
MYSQL_BIND result[2];
memset(result, 0, 2 * sizeof(MYSQL_BIND));
setBindValue<0>(result, nameId);
setBindValue<1>(result, lineCount);
if (mysql_stmt_bind_param(this->_getBigramCountStatement, param))
{
std::cout << "Binding parameters to prepared statement failed" << std::endl;
throw 0;
}
if (mysql_stmt_bind_result(this->_getBigramCountStatement, result))
{
std::cout << "Binding result to prepared statement failed" << std::endl;
throw 0;
}
if (mysql_stmt_execute(this->_getBigramCountStatement))
{
std::cout << "Executing select from bigram count failed" << mysql_stmt_error(this->_getBigramCountStatement) << std::endl;
throw 0;
}
mysql_stmt_store_result(this->_getBigramCountStatement);
TupleList resultSet;
while (!mysql_stmt_fetch(this->_getBigramCountStatement))
resultSet.push_back(make_tuple(static_cast<int>(nameId), static_cast<int>(lineCount)));
return resultSet;
}
示例2: read_faces
ErrorCode ReadCCMIO::read_faces(CCMIOID faceID,
CCMIOEntity bdy_or_int,
TupleList &vert_map,
TupleList &face_map
#ifndef TUPLE_LIST
,SenseList &sense_map
#endif
, Range *new_faces)
{
if (kCCMIOInternalFaces != bdy_or_int && kCCMIOBoundaryFaces != bdy_or_int)
CHKERR(MB_FAILURE, "Face type isn't boundary or internal.");
CCMIOSize_t dum_faces;
CCMIOError error = kCCMIONoErr;
CCMIOEntitySize(&error, faceID, &dum_faces, NULL);
int num_faces = GETINT32(dum_faces);
// get the size of the face connectivity array (not really a straight connect
// array, has n, connect(n), ...)
CCMIOSize_t farray_size = CCMIOSIZEC(0);
CCMIOReadFaces(&error, faceID, bdy_or_int, NULL, &farray_size, NULL,
CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
CHKCCMERR(error, "Trouble reading face connectivity length.");
// allocate vectors for holding farray and cells for each face; use new for finer
// control of de-allocation
int num_sides = (kCCMIOInternalFaces == bdy_or_int ? 2 : 1);
int *farray = new int[GETINT32(farray_size)];
// read farray and make the faces
CCMIOID mapID;
CCMIOReadFaces(&error, faceID, bdy_or_int, &mapID, NULL,
farray, CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
CHKCCMERR(error, "Trouble reading face connectivity.");
std::vector<EntityHandle> face_handles;
ErrorCode rval = make_faces(farray, vert_map, face_handles, num_faces);
CHKERR(rval, NULL);
// read face cells and make tuples
int *face_cells;
if (num_sides*num_faces < farray_size) face_cells = new int[num_sides*num_faces];
else face_cells = farray;
CCMIOReadFaceCells(&error, faceID, bdy_or_int, face_cells,
CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
CHKCCMERR(error, "Trouble reading face cells.");
int *tmp_ptr = face_cells;
for (unsigned int i = 0; i < face_handles.size(); i++) {
#ifdef TUPLE_LIST
short forward = 1, reverse = -1;
face_map.push_back(&forward, tmp_ptr++, &face_handles[i], NULL);
if (2 == num_sides)
face_map.push_back(&reverse, tmp_ptr++, &face_handles[i], NULL);
#else
face_map[*tmp_ptr].push_back(face_handles[i]);
sense_map[*tmp_ptr++].push_back(1);
if (2 == num_sides) {
face_map[*tmp_ptr].push_back(face_handles[i]);
sense_map[*tmp_ptr++].push_back(-1);
}
#endif
}
// now read & set face gids, reuse face_cells 'cuz we know it's big enough
CCMIOReadMap(&error, mapID, face_cells, CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
CHKCCMERR(error, "Trouble reading face gids.");
rval = mbImpl->tag_set_data(mGlobalIdTag, &face_handles[0], face_handles.size(), face_cells);
CHKERR(rval, "Couldn't set face global ids.");
// make a neumann set for these faces if they're all in a boundary face set
if (kCCMIOBoundaryFaces == bdy_or_int) {
EntityHandle neuset;
rval = mbImpl->create_meshset(MESHSET_SET, neuset);
CHKERR(rval, "Failed to create neumann set.");
// don't trust entity index passed in
int index;
CCMIOGetEntityIndex(&error, faceID, &index);
newNeusets[index] = neuset;
rval = mbImpl->add_entities(neuset, &face_handles[0], face_handles.size());
CHKERR(rval, "Failed to add faces to neumann set.");
// now tag as neumann set; will add id later
int dum_val = 0;
rval = mbImpl->tag_set_data(mNeumannSetTag, &neuset, 1, &dum_val);
CHKERR(rval, "Failed to tag neumann set.");
}
if (new_faces) {
std::sort(face_handles.begin(), face_handles.end());
std::copy(face_handles.rbegin(), face_handles.rend(), range_inserter(*new_faces));
}
return MB_SUCCESS;
}
示例3: read_vertices
ErrorCode ReadCCMIO::read_vertices(CCMIOSize_t /* proc */, CCMIOID /* processorID */, CCMIOID verticesID,
CCMIOID /* topologyID */,
Range *verts, TupleList &vert_map)
{
CCMIOError error = kCCMIONoErr;
// pre-read the number of vertices, so we can pre-allocate & read directly in
CCMIOSize_t nverts = CCMIOSIZEC(0);
CCMIOEntitySize(&error, verticesID, &nverts, NULL);
CHKCCMERR(error, "Couldn't get number of vertices.");
// get # dimensions
CCMIOSize_t dims;
float scale;
CCMIOReadVerticesf(&error, verticesID, &dims, NULL, NULL, NULL, CCMIOINDEXC(0), CCMIOINDEXC(1));
CHKCCMERR(error, "Couldn't get number of dimensions.");
// allocate vertex space
EntityHandle node_handle = 0;
std::vector<double*> arrays;
readMeshIface->get_node_coords(3, GETINT32(nverts), MB_START_ID, node_handle, arrays);
// read vertex coords
CCMIOID mapID;
std::vector<double> tmp_coords(GETINT32(dims)*GETINT32(nverts));
CCMIOReadVerticesd(&error, verticesID, &dims, &scale, &mapID, &tmp_coords[0],
CCMIOINDEXC(0), CCMIOINDEXC(0+nverts));
CHKCCMERR(error, "Trouble reading vertex coordinates.");
// copy interleaved coords into moab blocked coordinate space
int i = 0, threei = 0;
for (; i < nverts; i++) {
arrays[0][i] = tmp_coords[threei++];
arrays[1][i] = tmp_coords[threei++];
if (3 == GETINT32(dims)) arrays[2][i] = tmp_coords[threei++];
else arrays[2][i] = 0.0;
}
// scale, if necessary
if (1.0 != scale) {
for(i = 0; i < nverts; i++) {
arrays[0][i] *= scale;
arrays[1][i] *= scale;
if (3 == GETINT32(dims)) arrays[2][i] *= scale;
}
}
// read gids for vertices
std::vector<int> gids(GETINT32(nverts));
CCMIOReadMap(&error, mapID, &gids[0], CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
CHKCCMERR(error, "Trouble reading vertex global ids.");
// put new vertex handles into range, and set gids for them
Range new_verts(node_handle, node_handle+nverts-1);
ErrorCode rval = mbImpl->tag_set_data(mGlobalIdTag, new_verts, &gids[0]);
CHKERR(rval, "Couldn't set gids on vertices.");
// pack vert_map with global ids and handles for these vertices
#ifdef TUPLE_LIST
vert_map.resize(GETINT32(nverts));
for (i = 0; i < GETINT32(nverts); i++) {
vert_map.push_back(NULL, &gids[i], &node_handle, NULL);
#else
for (i = 0; i < GETINT32(nverts); i++) {
(vert_map[gids[i]]).push_back(node_handle);
#endif
node_handle += 1;
}
if (verts) verts->merge(new_verts);
return MB_SUCCESS;
}
ErrorCode ReadCCMIO::get_processors(CCMIOID stateID,
CCMIOID &processorID, CCMIOID &verticesID,
CCMIOID &topologyID, CCMIOID &solutionID,
std::vector<CCMIOSize_t> &procs,
bool & /* has_solution */)
{
CCMIOSize_t proc = CCMIOSIZEC(0);
CCMIOError error = kCCMIONoErr;
CCMIONextEntity(&error, stateID, kCCMIOProcessor, &proc, &processorID);
CHKCCMERR(error, NULL);
if (CCMIOReadProcessor(NULL, processorID, &verticesID,
&topologyID, NULL, &solutionID) != kCCMIONoErr) {
// Maybe no solution; try again
CCMIOReadProcessor(&error, processorID, &verticesID,
&topologyID, NULL, NULL);
hasSolution = false;
}
CHKCCMERR(error, NULL);
procs.push_back(proc);
return MB_SUCCESS;
}