本文整理汇总了C++中boost::ptr_vector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr_vector::size方法的具体用法?C++ ptr_vector::size怎么用?C++ ptr_vector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::ptr_vector
的用法示例。
在下文中一共展示了ptr_vector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_prediction
void llvm_model::set_prediction(const ObsId & obs_id, boost::ptr_vector<theta::Function> & coeffs_, boost::ptr_vector<HistogramFunction> & histos_){
observables.insert(obs_id);
const size_t n = coeffs_.size();
if(n!=coeffs_.size()) throw invalid_argument("Model::setPrediction: number of histograms and coefficients do not match");
if(histos[obs_id].size()>0 || coeffs[obs_id].size()>0)
throw invalid_argument("Model::setPrediction: prediction already set for this observable");
coeffs[obs_id].transfer(coeffs[obs_id].end(), coeffs_.begin(), coeffs_.end(), coeffs_);
histos[obs_id].transfer(histos[obs_id].end(), histos_.begin(), histos_.end(), histos_);
for(boost::ptr_vector<theta::Function>::const_iterator it=coeffs[obs_id].begin(); it!=coeffs[obs_id].end(); ++it){
ParIds pids = (*it).get_parameters();
parameters.insert(pids.begin(), pids.end());
}
size_t nbins = 0;
double xmin = NAN, xmax = NAN;
bool first = true;
for(boost::ptr_vector<HistogramFunction>::const_iterator it=histos[obs_id].begin(); it!=histos[obs_id].end(); ++it){
if(first){
it->get_histogram_dimensions(nbins, xmin, xmax);
first = false;
}
else{
size_t nbins_tmp = 0;
double xmin_tmp = NAN, xmax_tmp = NAN;
it->get_histogram_dimensions(nbins_tmp, xmin_tmp, xmax_tmp);
if(nbins!=nbins_tmp || xmin!=xmin_tmp || xmax!=xmax_tmp){
throw invalid_argument("llvm_model::set_prediction: histogram dimensions mismatch");
}
}
const ParIds & pids = (*it).get_parameters();
parameters.insert(pids.begin(), pids.end());
}
}
示例2: renderScene
void renderScene() {
FrameTimeCounter counter;
int avgFps = 0;
int iterations = 0;
while (!complete) {
counter.BeginCounting();
physicsWorld->Simulate(1.0f / 10.0f);
contextPtr->BeginScene();
contextPtr->ApplyCamera(*cameraPtr);
//contextPtr->RenderLine(vec2(0.0f, 0.0f), vec2(100.0f, 100.0f));
for (int i = 0; i < physicsBodies.size(); ++i) {
physicsBodies[i].DebugRender(debugRenderer);
}
for (int i = 0; i < physicsJoints.size(); ++i) {
physicsJoints[i].DebugRender(debugRenderer);
}
contextPtr->EndScene();
counter.EndCounting();
avgFps += counter.GetFps();
iterations++;
if (iterations > 10) {
SetWindowTextA(hWnd, formatString("fps: %d", avgFps / iterations).c_str());
iterations = 0;
avgFps = 0;
}
}
}
示例3: from_wkb
bool geometry_utils::from_wkb(boost::ptr_vector<geometry_type>& paths,
const char* wkb,
unsigned size,
wkbFormat format)
{
std::size_t geom_count = paths.size();
wkb_reader reader(wkb, size, format);
reader.read(paths);
if (paths.size() > geom_count)
return true;
return false;
}
示例4: fetch
inline bool command::fetch(std::vector<variant>& row)
{
if (0 == m_hnd.stmt) return false;
if (m_cols.empty()) columns();
const sword r(lib::singleton().p_OCIStmtFetch2(m_hnd.stmt, m_hnd.err, 1, OCI_FETCH_NEXT, 1, OCI_DEFAULT));
if (OCI_NO_DATA == r) return false;
m_hnd.check(r);
row.resize(m_cols.size());
for (size_t i(0); i < m_cols.size(); ++i)
m_cols[i](row[i]);
return true;
}
示例5: fetch
inline bool command::fetch(std::vector<variant>& row)
{
if (!m_stmt) return false;
if (m_cols.empty()) columns();
const int r(lib::singleton().p_mysql_stmt_fetch(m_stmt));
if (MYSQL_NO_DATA == r) return false;
check(1 != r);
row.resize(m_cols.size());
for (size_t i(0); i < m_cols.size(); ++i)
check(m_cols[i](m_stmt, (unsigned int)i, row[i]) == 0);
return true;
}
示例6: fetch
inline bool command::fetch(std::vector<variant>& row)
{
if (lib::error(m_req)) return false;
if (m_cols.empty()) columns();
const int r(lib::singleton().p_cci_cursor(m_req, 1, CCI_CURSOR_CURRENT, &m_err));
if (CCI_ER_NO_MORE_DATA == r) return false;
check(r);
check(lib::singleton().p_cci_fetch(m_req, &m_err));
row.resize(m_cols.size());
for (size_t i(0); i < m_cols.size(); ++i)
if (lib::error(m_cols[i](m_req, i, row[i]))) throw std::runtime_error("CUBRID error");
return true;
}
示例7: specialValue
const Value MessageSelectorEnv::specialValue(const string& id) const
{
Value v;
// TODO: Just use a simple if chain for now - improve this later
if ( id=="delivery_mode" ) {
v = msg.getEncoding().isPersistent() ? PERSISTENT : NON_PERSISTENT;
} else if ( id=="redelivered" ) {
v = msg.getDeliveryCount()>0 ? true : false;
} else if ( id=="priority" ) {
v = int64_t(msg.getPriority());
} else if ( id=="correlation_id" ) {
MessageId cId = msg.getEncoding().getCorrelationId();
if (cId) {
returnedStrings.push_back(new string(cId.str()));
v = returnedStrings[returnedStrings.size()-1];
}
} else if ( id=="message_id" ) {
MessageId mId = msg.getEncoding().getMessageId();
if (mId) {
returnedStrings.push_back(new string(mId.str()));
v = returnedStrings[returnedStrings.size()-1];
}
} else if ( id=="to" ) {
v = EMPTY; // Hard to get this correct for both 1.0 and 0-10
} else if ( id=="reply_to" ) {
v = EMPTY; // Hard to get this correct for both 1.0 and 0-10
} else if ( id=="absolute_expiry_time" ) {
qpid::sys::AbsTime expiry = msg.getExpiration();
// Java property has value of 0 for no expiry
v = (expiry==qpid::sys::FAR_FUTURE) ? 0
: qpid::sys::Duration(qpid::sys::AbsTime::Epoch(), expiry) / qpid::sys::TIME_MSEC;
} else if ( id=="creation_time" ) {
// Use the time put on queue (if it is enabled) as 0-10 has no standard way to get message
// creation time and we're not paying attention to the 1.0 creation time yet.
v = int64_t(msg.getTimestamp() * 1000); // getTimestamp() returns time in seconds we need milliseconds
} else if ( id=="jms_type" ) {
// Currently we can't distinguish between an empty JMSType and no JMSType
// We'll assume for now that setting an empty JMSType doesn't make a lot of sense
const string jmsType = msg.getAnnotation("jms-type").asString();
if ( !jmsType.empty() ) {
returnedStrings.push_back(new string(jmsType));
v = returnedStrings[returnedStrings.size()-1];
}
} else {
v = Value();
}
return v;
}
示例8: sqrt
double distance::getEuclidean2(boost::ptr_vector<double>& v1, boost::ptr_vector<double>& v2)
{
double euclidean = 0;
int n = v1.size() == v2.size() ? v1.size() : 0;
if (n > 0)
{
for (boost::ptr_vector<double>::iterator it1 = v1.begin(), it2 = v2.begin(); it1 != v1.end(), it2 != v2.end(); it1++, it2++)
{
euclidean += (*it1 - *it2)*(*it1 - *it2);
}
euclidean = sqrt(euclidean);
return euclidean;
}
else
return (double)-1;
}
示例9: set
void set(const string& id, const qb::Value& value) {
if (value.type==qb::Value::T_STRING) {
strings.push_back(new string(*value.s));
values[id] = strings[strings.size()-1];
} else {
values[id] = value;
}
}
示例10:
typename Argc_T<CON>::type Argc_T<CON>::
getData(RLMachine& machine,
const boost::ptr_vector<libReallive::ExpressionPiece>& p,
unsigned int& position) {
type return_vector;
for (; position < p.size(); )
return_vector.push_back(CON::getData(machine, p, position));
return return_vector;
}
示例11: set_target
void set_target(engine::pointer z){
//cooltime();
if (cooldown < 1){
for(short i = 0; i < ammo.size(); i++){
if (!ammo[i].fired){
ammo[i].fired = true;
break;
}
}
}
}
示例12: init
void init(unsigned int thread_count)
{
voxel_data.resize(thread_count);
for (unsigned int index = 0; index < thread_count; ++index)
{
voxel_data[index].space.resize(q_count);
voxel_data[index].odf.resize(ti.half_vertices_count);
voxel_data[index].fa.resize(max_fiber_number);
voxel_data[index].dir_index.resize(max_fiber_number);
voxel_data[index].dir.resize(max_fiber_number);
}
for (unsigned int index = 0; index < process_list.size(); ++index)
process_list[index].init(*this);
}
示例13: getObjForce
/// compute the resulting force of all force field objects.
d_vector getObjForce(vrpn_float64 *pos, vrpn_float64 *vel) {
int i;
for (i=0; i<3; ++i) {
m_curforce[i]=0.0;
m_curpos[i]=pos[i];
m_curvel[i]=vel[i];
}
// force field objects
int nobj = m_FFEffects.size();
for (i=0; i<nobj; ++i) {
m_curforce = m_curforce + m_FFEffects[i].calcForce (m_curpos);
}
return m_curforce;
};
示例14: thread_run
void thread_run(unsigned char thread_index,unsigned char thread_count,
const std::vector<unsigned char>& mask)
{
unsigned int sum_mask = std::accumulate(mask.begin(),mask.end(),(unsigned int)0)/thread_count;
unsigned int cur = 0;
for(unsigned int voxel_index = thread_index;
voxel_index < dim.size() &&
(thread_index != 0 || check_prog(cur,sum_mask));voxel_index += thread_count)
{
if (!mask[voxel_index])
continue;
cur += mask[voxel_index];
voxel_data[thread_index].init();
voxel_data[thread_index].voxel_index = voxel_index;
for (int index = 0; index < process_list.size(); ++index)
process_list[index].run(*this,voxel_data[thread_index]);
if(prog_aborted())
break;
}
}
示例15: end
void end(MatFile& writer)
{
for (unsigned int index = 0; index < process_list.size(); ++index)
process_list[index].end(*this,writer);
}