本文整理汇总了C++中std::vector::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::insert方法的具体用法?C++ vector::insert怎么用?C++ vector::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::vector
的用法示例。
在下文中一共展示了vector::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSequence
bool XmlSchemaGenerator::getSequence ( std::vector<wxString> &sequence,
const std::map<wxString, ChildData> &elmtMap )
{
bool deadlock = false;
sequence.clear();
std::vector<wxString>::iterator seqItr, seqFindItr;
std::set<wxString>::const_iterator prevItr, prevEnd;
std::map<wxString, ChildData>::const_iterator itr;
bool retry;
do
{
retry = false;
for ( itr = elmtMap.begin(); itr != elmtMap.end(); ++itr )
{
seqFindItr = std::find ( sequence.begin(), sequence.end(),
itr->first );
if ( seqFindItr != sequence.end() )
continue;
seqItr = sequence.begin();
prevItr = itr->second.prevSiblings.begin();
prevEnd = itr->second.prevSiblings.end();
for ( ; prevItr != prevEnd; ++prevItr )
{ // Find last index of dependent elements
seqFindItr = std::find ( sequence.begin(), sequence.end(),
*prevItr );
if ( seqFindItr != sequence.end() )
{
if ( seqItr < seqFindItr )
{
seqItr = seqFindItr;
}
continue;
}
const std::set<wxString> &previous =
elmtMap.find ( *prevItr )->second.prevSiblings;
if ( previous.find ( itr->first ) == previous.end() )
{ // Not a deadlock
retry = true;
break;
}
else
{
deadlock = true;
}
}
if ( prevItr != prevEnd )
continue; // The preceding doesn't exist
if ( seqItr != sequence.end() )
{
++seqItr;
}
sequence.insert ( seqItr, itr->first );
wxLogDebug ( _T(" %s"), itr->first.c_str() );
}
} while ( retry );
return !deadlock;
}
示例2: move
BoolQ && should(std::initializer_list<Query> queries) &&
{
_should.insert(_must.end(), queries);
return std::move(*this);
}
示例3: it
void
ImageProcessing::SegmentColours( FrameBuffer * frame,
FrameBuffer * outFrame,
unsigned int threshold,
unsigned int minLength,
unsigned int minSize,
unsigned int subSample,
ColourDefinition const & target,
RawPixel const & mark,
std::vector<VisionObject> & results
)
{
FrameBufferIterator it( frame );
FrameBufferIterator oit( outFrame );
Pixel cPixel;
RawPixel oPixel;
// unsigned int len;
FloodFillState state;
unsigned int count;
for( unsigned int row = 0; row < frame->height; row = row + subSample )
{
it.goPosition(row, subSample);
oit.goPosition(row, subSample);
count = 0;
for( unsigned int col = subSample; col < frame->width; col = col + subSample, it.goRight( subSample ),oit.goRight( subSample ) )
{
oit.getPixel( & oPixel );
if ( oPixel == RawPixel( 0, 0, 0 ) )
{
it.getPixel( & cPixel );
if ( target.isMatch( cPixel ) )
{
count++;
}
else
{
count = 0;
}
if ( count >= minLength )
{
state.initialize();
doFloodFill( frame, outFrame, Point( col, row),
cPixel, threshold, & target,
subSample, & state );
#ifdef XX_DEBUG
if ( state.size() > minSize )
{
std::cout << "Flood fill returns size " << state.size() << std::endl;
}
#endif
if ( state.size() > minSize )
{
unsigned int tlx = state.bBox().topLeft().x();
unsigned int tly = state.bBox().topLeft().y();
unsigned int brx = state.bBox().bottomRight().x();
unsigned int bry = state.bBox().bottomRight().y();
drawBresenhamLine( outFrame, tlx, tly, tlx, bry, mark );
drawBresenhamLine( outFrame, tlx, bry, brx, bry, mark );
drawBresenhamLine( outFrame, brx, bry, brx, tly, mark );
drawBresenhamLine( outFrame, brx, tly, tlx, tly, mark );
drawBresenhamLine( frame, tlx, tly, tlx, bry, mark );
drawBresenhamLine( frame, tlx, bry, brx, bry, mark );
drawBresenhamLine( frame, brx, bry, brx, tly, mark );
drawBresenhamLine( frame, brx, tly, tlx, tly, mark );
// swapColours( outFrame, 0, state.bBox(), 1, ColourDefinition( Pixel(colour), Pixel(colour) ), state.averageColour() );
VisionObject vo( target.name, state.size(), state.x(), state.y(), state.averageColour(), state.bBox() );
std::vector<VisionObject>::iterator i;
for( i = results.begin();
i != results.end();
++i)
{
if ( (*i).size < vo.size )
{
break;
}
}
results.insert(i, vo );
}
count = 0;
}
}
else
{
count = 0;
}
}
}
}
示例4: getMatrixOrthonormalBasis
void SingleQubitGateStoreImpl::getMatrixOrthonormalBasis(std::vector<MatrixPtr>& pBasis) {
pBasis.insert(pBasis.end(), m_basis2.begin(), m_basis2.end());
}
示例5: fileDrop
void SphericalStereoApp::fileDrop( FileDropEvent event )
{
mPanos.insert( mPanos.begin() + mPanoIndex, Pano{ event.getFile( 0 ) } );
}
示例6: compute
//.........这里部分代码省略.........
cv::Mat temp(wholeSize, _image.type()), masktemp;
imagePyramid[level] = temp(cv::Rect(border, border, sz.width, sz.height));
// Compute the resized image
if( level != firstLevel )
{
if( level < firstLevel )
resize(_image, imagePyramid[level], sz, 0, 0, cv::INTER_LINEAR);
else
resize(imagePyramid[level-1], imagePyramid[level], sz, 0, 0, cv::INTER_LINEAR);
cv::copyMakeBorder(imagePyramid[level], temp, border, border, border, border,
cv::BORDER_REFLECT_101+cv::BORDER_ISOLATED);
}
else
cv::copyMakeBorder(_image, temp, border, border, border, border,
cv::BORDER_REFLECT_101);
}
// Pre-compute the keypoints (we keep the best over all scales, so this has to be done beforehand
std::vector < std::vector<cv::KeyPoint> > allKeypoints;
// Cluster the input keypoints depending on the level they were computed at
allKeypoints.resize(levelsNum);
for (std::vector<cv::KeyPoint>::iterator keypoint = _keypoints.begin(),
keypointEnd = _keypoints.end(); keypoint != keypointEnd; ++keypoint)
allKeypoints[keypoint->octave].push_back(*keypoint);
// Make sure we rescale the coordinates
for (int level = 0; level < levelsNum; ++level)
{
if (level == firstLevel)
continue;
std::vector<cv::KeyPoint> & keypoints = allKeypoints[level];
float scale = 1/getScale(level, firstLevel, scaleFactor);
for (std::vector<cv::KeyPoint>::iterator keypoint = keypoints.begin(),
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
keypoint->pt *= scale;
}
cv::Mat descriptors;
std::vector<cv::Point> pattern;
int nkeypoints = 0;
for (int level = 0; level < levelsNum; ++level){
std::vector<cv::KeyPoint>& keypoints = allKeypoints[level];
cv::Mat& workingmat = imagePyramid[level];
if(keypoints.size() > 1)
cv::KeyPointsFilter::runByImageBorder(keypoints, workingmat.size(), border);
nkeypoints += keypoints.size();
}
if( nkeypoints == 0 )
_descriptors.release();
else
{
_descriptors.create(nkeypoints, descriptorSize(), CV_8U);
descriptors = _descriptors;
}
_keypoints.clear();
int offset = 0;
for (int level = 0; level < levelsNum; ++level)
{
// preprocess the resized image
cv::Mat& workingmat = imagePyramid[level];
// Get the features and compute their orientation
std::vector<cv::KeyPoint>& keypoints = allKeypoints[level];
if(keypoints.size() > 1)
cv::KeyPointsFilter::runByImageBorder(keypoints, workingmat.size(), border);
int nkeypoints = (int)keypoints.size();
// Compute the descriptors
cv::Mat desc;
if (!descriptors.empty())
{
desc = descriptors.rowRange(offset, offset + nkeypoints);
}
offset += nkeypoints;
//boxFilter(working_cv::Mat, working_cv::Mat, working_cv::Mat.depth(), Size(5,5), Point(-1,-1), true, BORDER_REFLECT_101);
GaussianBlur(workingmat, workingmat, cv::Size(7, 7), 2, 2, cv::BORDER_REFLECT_101);
cv::Mat integral_image;
integral(workingmat, integral_image, CV_32S);
computeDescriptors(workingmat, integral_image, patchSize, keypoints, desc, descriptorSize(), flag);
// Copy to the output data
if (level != firstLevel)
{
float scale = getScale(level, firstLevel, scaleFactor);
for (std::vector<cv::KeyPoint>::iterator keypoint = keypoints.begin(),
keypointEnd = keypoints.end(); keypoint != keypointEnd; ++keypoint)
keypoint->pt *= scale;
}
// And add the keypoints to the output
_keypoints.insert(_keypoints.end(), keypoints.begin(), keypoints.end());
}
}
示例7: addParamsFrom
/// @brief Add the parameters of Source to this result.
void addParamsFrom(const ValidatorResult &Source) {
Parameters.insert(Parameters.end(), Source.Parameters.begin(),
Source.Parameters.end());
}
示例8: prependVec
void prependVec(std::vector<T>& vec, const std::vector<T>& otherVec) {
vec.insert(vec.begin(), otherVec.begin(), otherVec.end());
}
示例9: GetScanResults
void CJoystickInterfaceCallback::GetScanResults(std::vector<CJoystick*>& joysticks)
{
joysticks.insert(joysticks.end(), m_scanResults.begin(), m_scanResults.end());
m_scanResults.clear();
}
示例10:
void CPrimitiveClass::CParameter::CConstStringValue::appendFilePath(std::vector<std::string> &pathList) const
{
pathList.insert(pathList.end(), Values.begin(), Values.end());
}
示例11: InitializePredefinedMacros
//.........这里部分代码省略.........
assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
DefineTypeSize("__SCHAR_MAX__", TI.getCharWidth(), "", true, Buf);
DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Buf);
DefineTypeSize("__INT_MAX__", TargetInfo::SignedInt, TI, Buf);
DefineTypeSize("__LONG_MAX__", TargetInfo::SignedLong, TI, Buf);
DefineTypeSize("__LONG_LONG_MAX__", TargetInfo::SignedLongLong, TI, Buf);
DefineTypeSize("__WCHAR_MAX__", TI.getWCharType(), TI, Buf);
DefineTypeSize("__INTMAX_MAX__", TI.getIntMaxType(), TI, Buf);
DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf);
DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf);
DefineTypeWidth("__INTMAX_WIDTH__", TI.getIntMaxType(), TI, Buf);
DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Buf);
DefineTypeWidth("__PTRDIFF_WIDTH__", TI.getPtrDiffType(0), TI, Buf);
DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Buf);
DefineTypeWidth("__INTPTR_WIDTH__", TI.getIntPtrType(), TI, Buf);
DefineType("__SIZE_TYPE__", TI.getSizeType(), Buf);
DefineTypeWidth("__SIZE_WIDTH__", TI.getSizeType(), TI, Buf);
DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf);
DefineTypeWidth("__WCHAR_WIDTH__", TI.getWCharType(), TI, Buf);
DefineType("__WINT_TYPE__", TI.getWIntType(), Buf);
DefineTypeWidth("__WINT_WIDTH__", TI.getWIntType(), TI, Buf);
DefineTypeWidth("__SIG_ATOMIC_WIDTH__", TI.getSigAtomicType(), TI, Buf);
DefineFloatMacros(Buf, "FLT", &TI.getFloatFormat());
DefineFloatMacros(Buf, "DBL", &TI.getDoubleFormat());
DefineFloatMacros(Buf, "LDBL", &TI.getLongDoubleFormat());
// Define a __POINTER_WIDTH__ macro for stdint.h.
sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
DefineBuiltinMacro(Buf, MacroBuf);
if (!LangOpts.CharIsSigned)
DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
// Define exact-width integer types for stdint.h
sprintf(MacroBuf, "__INT%d_TYPE__=char", TI.getCharWidth());
DefineBuiltinMacro(Buf, MacroBuf);
if (TI.getShortWidth() > TI.getCharWidth())
DefineExactWidthIntType(TargetInfo::SignedShort, TI, Buf);
if (TI.getIntWidth() > TI.getShortWidth())
DefineExactWidthIntType(TargetInfo::SignedInt, TI, Buf);
if (TI.getLongWidth() > TI.getIntWidth())
DefineExactWidthIntType(TargetInfo::SignedLong, TI, Buf);
if (TI.getLongLongWidth() > TI.getLongWidth())
DefineExactWidthIntType(TargetInfo::SignedLongLong, TI, Buf);
// Add __builtin_va_list typedef.
{
const char *VAList = TI.getVAListDeclaration();
Buf.insert(Buf.end(), VAList, VAList+strlen(VAList));
Buf.push_back('\n');
}
if (const char *Prefix = TI.getUserLabelPrefix()) {
sprintf(MacroBuf, "__USER_LABEL_PREFIX__=%s", Prefix);
DefineBuiltinMacro(Buf, MacroBuf);
}
// Build configuration options. FIXME: these should be controlled by
// command line options or something.
DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
if (LangOpts.GNUInline)
DefineBuiltinMacro(Buf, "__GNUC_GNU_INLINE__=1");
else
DefineBuiltinMacro(Buf, "__GNUC_STDC_INLINE__=1");
if (LangOpts.NoInline)
DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
if (unsigned PICLevel = LangOpts.PICLevel) {
sprintf(MacroBuf, "__PIC__=%d", PICLevel);
DefineBuiltinMacro(Buf, MacroBuf);
sprintf(MacroBuf, "__pic__=%d", PICLevel);
DefineBuiltinMacro(Buf, MacroBuf);
}
// Macros to control C99 numerics and <float.h>
DefineBuiltinMacro(Buf, "__FLT_EVAL_METHOD__=0");
DefineBuiltinMacro(Buf, "__FLT_RADIX__=2");
sprintf(MacroBuf, "__DECIMAL_DIG__=%d",
PickFP(&TI.getLongDoubleFormat(), -1/*FIXME*/, 17, 21, 33, 36));
DefineBuiltinMacro(Buf, MacroBuf);
if (LangOpts.getStackProtectorMode() == LangOptions::SSPOn)
DefineBuiltinMacro(Buf, "__SSP__=1");
else if (LangOpts.getStackProtectorMode() == LangOptions::SSPReq)
DefineBuiltinMacro(Buf, "__SSP_ALL__=2");
// Get other target #defines.
TI.getTargetDefines(LangOpts, Buf);
}
示例12: addBaselineModes
void MultiGaussianDistribution::addBaselineModes(std::vector<SimpleGaussian*> &distribution) {
std::vector<SimpleGaussian*> baseline = SimpleGaussian::createBaselineGaussians();
distribution.insert(distribution.end(), baseline.begin(), baseline.end());
}
示例13: rtp_single_objective
std::unique_ptr< i_population_wide_observer > resultant_objective::create_instance(
prm::param_accessor param,
std::vector< std::unique_ptr< i_observer > >& required_observations)
//std::set< agent_objective::Type >& required_observations)
{
#if 0
auto type = prm::find_value(param, "obj_type")[0].as< i_population_wide_observer::Type >();
switch(type)
{
case i_population_wide_observer::Single:
{
auto ao_type = prm::find_value(param, "single_obj")[0].as< agent_objective::Type >();
required_observations.insert(ao_type);
return new rtp_single_objective(agent_objective::Names[ao_type]);
}
case i_population_wide_observer::Pareto:
{
auto ep = prm::find_value(param, "pareto_obj").as< prm::enum_param_val >();
auto objectives = boost::any_cast<std::vector< std::string >>(ep.contents);
for(auto const& obj_name : objectives)
{
required_observations.insert(YAML::Node(obj_name).as< agent_objective::Type >());
}
/* std::vector< std::string > obj_names;
for(auto const& obj : agent_objective::Names)
{
if(prm::find_value(param, obj).as< bool >())
{
required_observations.insert(YAML::Node(obj).as< agent_objective::Type >());
obj_names.push_back(obj);
}
}
*/
return new rtp_pareto(objectives);// obj_names);
}
default:
return nullptr;
}
#endif
param.push_relative_path(prm::qualified_path("objective"));
auto obj_type = param["obj_type"][0].as< i_population_wide_observer::Type >();
param.push_relative_path(prm::qualified_path("objective_components"));
std::unique_ptr< i_population_wide_observer > result;
switch(obj_type)
{
case i_population_wide_observer::Type::Single:
{
auto man_obj = manual_objective::create_instance(param, std::function< double(state_value_id) >()); // TODO:
auto observation_name = std::string("SINGLE");
auto wrapped = std::make_unique< temp_manual_objective_wrapper >(std::move(man_obj), observation_name);
required_observations.emplace_back(std::move(wrapped));
// TODO:
auto merge = param["trial_merging"][0].as< std::string >();
rtp_single_objective::MergeMethod merge_method = rtp_single_objective::MergeMethod::Default;
if(merge == "Average")
{
merge_method = rtp_single_objective::MergeMethod::Average;
}
else
{
merge_method = rtp_single_objective::MergeMethod::Minimum;
}
result = std::make_unique< rtp_single_objective >(observation_name, merge_method);
}
break;
case i_population_wide_observer::Type::Pareto:
{
std::vector< std::string > components;
auto node = param["pareto_components"];
//assert(node[prm::ParamNode::Value] && node[prm::ParamNode::Value].IsMap());
assert(node.IsMap());
for(auto inst : node)//[prm::ParamNode::Value])
{
auto inst_num = inst.first.as< unsigned int >();
auto rel_path = prm::qualified_path("pareto_components");
rel_path.leaf().set_index(inst_num);
param.push_relative_path(rel_path);
auto man_obj = manual_objective::create_instance(param, std::function< double(state_value_id) >()); // TODO: ?? Currently set in every update() call, so this is not used...
// TODO: For now just using unique path as observation name
std::stringstream ss;
ss << rel_path;
auto observation_name = ss.str();
auto wrapped = std::make_unique< temp_manual_objective_wrapper >(std::move(man_obj), observation_name);
required_observations.emplace_back(std::move(wrapped));
param.pop_relative_path();
components.push_back(observation_name);
}
result = std::make_unique< rtp_pareto >(components);
}
break;
case i_population_wide_observer::Type::Null_Debug:
{
//.........这里部分代码省略.........
示例14: addOtherVec
void addOtherVec(std::vector<T>& reads, const std::vector<T>& otherVec) {
reads.reserve(reads.size() + otherVec.size());
reads.insert(reads.end(), otherVec.begin(), otherVec.end());
}
示例15: detect
//==============================================================//
void ObjDetector::detect(cv::Mat src, std::vector<cv::Rect>& box,
std::vector<float>& vote)
{
int i, j;
float m=m_slidParam.m_init_scale;
box.clear();
vote.clear();
std::cout << "original size: " << src.size() << std::endl;
std::cout << "objsize: " << m_objsize[0] << "/" << m_objsize[1] << "\n";
for(i=0; i<m_slidParam.m_scale_num; ++i, m*=m_slidParam.m_shrink_ratio) {
cv::Size newSize(src.cols*m, src.rows*m);
//std::cout << "objsize: " << m_objsize[0] << "/" << m_objsize[1] << "\n";
std::cout << i << ": scale " << m << "\n";
int maxlen = 2048;
if(newSize.width>maxlen || newSize.height>maxlen) {
std::cout << "**** image size > " << maxlen << "\n";
std::cout << "**** stop detection\n";
continue;
}
if(newSize.width<m_objsize[0] || newSize.height<m_objsize[1]) {
break;
}
cv::Mat resized;
cv::resize(src, resized, newSize, 0, 0, cv::INTER_AREA);
std::vector<cv::Rect> tempbox;
std::vector<float> tempvote;
detect_image(resized, m, tempbox, tempvote);
box.insert(box.end(), tempbox.begin(), tempbox.end());
vote.insert(vote.end(), tempvote.begin(), tempvote.end());
}
//remove overlapping area
if(m_remove_overlap) {
for(i=0; i<vote.size(); ++i) {
bool toremove=false;
for(j=0; j<vote.size(); ++j) {
if(i!=j)
{
if( vote[i]<=vote[j]
&& overlapRatio(box[i],box[j])>m_overlap_thres)
{
toremove=true;
break;
}
//if( (box[i]&box[j])==box[i] )
// && overlapRatio(box[i],box[j])>m_overlap_thres-0.1)
if( (box[i]&box[j]).area()/float(box[i].area())>0.85)
{
float cx = box[j].x+box[j].width/2.0;
float cy = box[j].y+box[j].height/2.0;
if( (box[i].x<cx && box[i].x+box[i].width >cx)
||(box[i].y<cy && box[i].y+box[i].height>cy) )
{
if(vote[i]<=vote[j]) {
toremove=true;
break;
}
else {
vote.erase(vote.begin()+j);
box.erase(box.begin()+j);
--j;
}
}
}
}
}
if(toremove) {
vote.erase(vote.begin()+i);
box.erase(box.begin()+i);
--i;
}
}
}
}