本文整理汇总了C++中container_type::size方法的典型用法代码示例。如果您正苦于以下问题:C++ container_type::size方法的具体用法?C++ container_type::size怎么用?C++ container_type::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类container_type
的用法示例。
在下文中一共展示了container_type::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hit_test
bool hit_test(value_type x, value_type y, double tol) const
{
if (cont_.size() == 1) {
// Handle points
double x0, y0;
cont_.get_vertex(0, &x0, &y0);
return distance(x, y, x0, y0) <= fabs(tol);
} else if (cont_.size() > 1) {
bool inside=false;
double x0=0;
double y0=0;
rewind(0);
vertex(&x0, &y0);
unsigned command;
double x1,y1;
while (SEG_END != (command=vertex(&x1, &y1)))
{
if (command == SEG_MOVETO)
{
x0 = x1;
y0 = y1;
continue;
}
if ((((y1 <= y) && (y < y0)) ||
((y0 <= y) && (y < y1))) &&
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
inside=!inside;
x0=x1;
y0=y1;
}
return inside;
}
return false;
}
示例2: triplets
std::vector<triplet> copy_triplets() {
std::vector<triplet> triplets(data.size());
size_type count = 0;
for(size_type brow=0; brow<_brows; ++brow) {
for(size_type bidx=brow_ptr[brow]; bidx<brow_ptr[brow+1]; ++bidx) {
size_type bcol = bcol_index[bidx];
for(size_type i=0; i<BLOCK; ++i) {
for(size_type j=0; j<BLOCK; ++j) {
std::get<0>(triplets[count]) = brow*BLOCK + i;
std::get<1>(triplets[count]) = bcol*BLOCK + j;
std::get<2>(triplets[count]) = data[index(bidx,i,j)];
++count;
}
}
}
}
return triplets;
}
示例3: while
static inline void add_to_hull(point_type const& p, container_type& output)
{
typedef typename strategy::side::services::default_strategy<cs_tag>::type side;
output.push_back(p);
std::size_t output_size = output.size();
while (output_size >= 3)
{
rev_iterator rit = output.rbegin();
point_type const last = *rit++;
point_type const& last2 = *rit++;
if (Factor * side::apply(*rit, last, last2) <= 0)
{
// Remove last two points from stack, and add last again
// This is much faster then erasing the one but last.
output.pop_back();
output.pop_back();
output.push_back(last);
output_size--;
}
else
{
return;
}
}
}
示例4: distance
/* summarized distance centroid */
void label_position3(double *x, double *y) const
{
if (type_ == LineString || type_ == MultiLineString)
{
middle_point(x,y);
return;
}
unsigned i = 0;
double l = 0.0;
double tl = 0.0;
double cx = 0.0;
double cy = 0.0;
double x0 = 0.0;
double y0 = 0.0;
double x1 = 0.0;
double y1 = 0.0;
unsigned size = cont_.size();
for (i = 0; i < size-1; i++)
{
cont_.get_vertex(i,&x0,&y0);
cont_.get_vertex(i+1,&x1,&y1);
l = distance(x0,y0,x1,y1);
cx += l * (x1 + x0)/2;
cy += l * (y1 + y0)/2;
tl += l;
}
*x = cx / tl;
*y = cy / tl;
}
示例5: bindex_of
inline size_type bindex_of(size_type I, size_type J, bool &in_sparsity) const {
for(size_type idx=brow_ptr[I]; idx<brow_ptr[I+1]; ++idx) {
if(J == bcol_index[idx]) {
in_sparsity = true;
return idx;
}
}
in_sparsity=false;
return data.size();
}
示例6: center_of_mass
//[ some_helpers
point_type center_of_mass( const container_type &x , const mass_type &m )
{
double overall_mass = 0.0;
point_type mean( 0.0 );
for( size_t i=0 ; i<x.size() ; ++i )
{
overall_mass += m[i];
mean += m[i] * x[i];
}
if( !x.empty() ) mean /= overall_mass;
return mean;
}
示例7: label_position
/* center of gravity centroid
- best visually but does not work with multipolygons
*/
void label_position(double *x, double *y) const
{
if (type_ == LineString || type_ == MultiLineString)
{
middle_point(x,y);
return;
}
unsigned size = cont_.size();
if (size < 3)
{
cont_.get_vertex(0,x,y);
return;
}
double ai;
double atmp = 0;
double xtmp = 0;
double ytmp = 0;
double x0 =0;
double y0 =0;
double x1 =0;
double y1 =0;
double ox =0;
double oy =0;
unsigned i;
// Use first point as origin to improve numerical accuracy
cont_.get_vertex(0,&ox,&oy);
for (i = 0; i < size-1; i++)
{
cont_.get_vertex(i,&x0,&y0);
cont_.get_vertex(i+1,&x1,&y1);
x0 -= ox; y0 -= oy;
x1 -= ox; y1 -= oy;
ai = x0 * y1 - x1 * y0;
atmp += ai;
xtmp += (x1 + x0) * ai;
ytmp += (y1 + y0) * ai;
}
if (atmp != 0)
{
*x = (xtmp/(3*atmp)) + ox;
*y = (ytmp/(3*atmp)) + oy;
return;
}
*x=x0;
*y=y0;
}
示例8: middle_point
void middle_point(double *x, double *y) const
{
// calculate mid point on path
double x0=0;
double y0=0;
double x1=0;
double y1=0;
unsigned size = cont_.size();
if (size == 1)
{
cont_.get_vertex(0,x,y);
}
else if (size == 2)
{
cont_.get_vertex(0,&x0,&y0);
cont_.get_vertex(1,&x1,&y1);
*x = 0.5 * (x1 + x0);
*y = 0.5 * (y1 + y0);
}
else
{
double len=0.0;
for (unsigned pos = 1; pos < size; ++pos)
{
cont_.get_vertex(pos-1,&x0,&y0);
cont_.get_vertex(pos,&x1,&y1);
double dx = x1 - x0;
double dy = y1 - y0;
len += std::sqrt(dx * dx + dy * dy);
}
double midlen = 0.5 * len;
double dist = 0.0;
for (unsigned pos = 1; pos < size;++pos)
{
cont_.get_vertex(pos-1,&x0,&y0);
cont_.get_vertex(pos,&x1,&y1);
double dx = x1 - x0;
double dy = y1 - y0;
double seg_len = std::sqrt(dx * dx + dy * dy);
if (( dist + seg_len) >= midlen)
{
double r = (midlen - dist)/seg_len;
*x = x0 + (x1 - x0) * r;
*y = y0 + (y1 - y0) * r;
break;
}
dist += seg_len;
}
}
}
示例9: energy
double energy( const container_type &q , const container_type &p , const mass_type &masses )
{
const size_t n = q.size();
double en = 0.0;
for( size_t i=0 ; i<n ; ++i )
{
en += 0.5 * norm( p[i] ) / masses[i];
for( size_t j=0 ; j<i ; ++j )
{
double diff = abs( q[i] - q[j] );
en -= gravitational_constant * masses[j] * masses[i] / diff;
}
}
return en;
}
示例10: operator
void operator()( const container_type &q , container_type &dpdt ) const
{
const size_t n = q.size();
for( size_t i=0 ; i<n ; ++i )
{
dpdt[i] = 0.0;
for( size_t j=0 ; j<i ; ++j )
{
point_type diff = q[j] - q[i];
double d = abs( diff );
diff *= ( gravitational_constant * m_masses[i] * m_masses[j] / d / d / d );
dpdt[i] += diff;
dpdt[j] -= diff;
}
}
}
示例11: make_pair
pair< double , double > calc_mean_field( const container_type &x )
{
size_t n = x.size();
double cos_sum = 0.0 , sin_sum = 0.0;
for( size_t i=0 ; i<n ; ++i )
{
cos_sum += cos( x[i] );
sin_sum += sin( x[i] );
}
cos_sum /= double( n );
sin_sum /= double( n );
double K = sqrt( cos_sum * cos_sum + sin_sum * sin_sum );
double Theta = atan2( sin_sum , cos_sum );
return make_pair( K , Theta );
}
示例12: size
//
// Capacity
//
size_t size() const { return list.size(); }
示例13: size
static std::size_t size(const container_type& p) { return p.size(); }
示例14: size
typename container_type::size_type size()
{
return m_queue.size();
}
示例15: operator
void operator()( const container_type &x , container_type &dxdt , double /* t */ ) const
{
pair< double , double > mean = calc_mean_field( x );
for( size_t i=0 ; i<x.size() ; ++i )
dxdt[i] = m_omega[i] + m_epsilon * mean.first * sin( mean.second - x[i] );
}