本文整理汇总了C++中Cont::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Cont::size方法的具体用法?C++ Cont::size怎么用?C++ Cont::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cont
的用法示例。
在下文中一共展示了Cont::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GAppSetOpts_ranged
inline void GAppSetOpts_ranged(const char *value, Cont& cont) {
cont.clear();
bool had_range = false;
const char *comma = value;
do {
uint32_t low = abs(atoi(comma)), high = low;
const char *delim = strchr(comma, '-');
const char *nextc = strchr(comma, ',');
if (delim && (nextc == 0 || nextc > delim)) {
had_range = true;
high = abs(atoi(delim + 1));
}
for (; low <= high; ++low) {
cont.push_back(low);
}
} while ((comma = strchr(comma, ',')) != 0 && ++comma && *comma != 0);
if (cont.size() == 1 && !had_range) {
uint32_t val = cont.front();
cont.clear();
for (uint32_t i = 1; i <= val; ++i) {
cont.push_back(i);
}
}
}
示例2: test_serialization_helper
void test_serialization_helper()
{
Cont vec;
add( vec, new Base( -1 ), 0u );
add( vec, new Derived( 1 ), 1u );
std::ofstream ofs("filename");
boost::archive::text_oarchive oa(ofs);
oa << as_const(vec);
ofs.close();
std::ifstream ifs("filename", std::ios::binary);
boost::archive::text_iarchive ia(ifs);
Cont vec2;
ia >> vec2;
ifs.close();
BOOST_CHECK_EQUAL( vec.size(), vec2.size() );
BOOST_CHECK_EQUAL( (*vec2.begin()).i, -1 );
BOOST_CHECK_EQUAL( (*--vec2.end()).i, 0 );
typename Cont::iterator i = vec2.end();
--i;
Derived* d = dynamic_cast<Derived*>( &*i );
BOOST_CHECK_EQUAL( d->i2, 1 );
}
示例3: average
NumericT average(const Cont<NumericT>& vals) const
{
std::cout << "lin average " << std::endl;
if (vals.size() == 0)
return NumericT(0.); // Concept:: neutral element
double dval(0.0);
for (unsigned int i(0); i < vals.size(); ++i)
{
double dv(*vals[i]);
dval += dv;
}
dval = dval/(double(vals.size()));
return NumericT(dval);
}
示例4: do_move
static void do_move(Cont& styls, int type, int& first, int& last, bool storage) {
auto begin = styls.begin();
// Move up
if (type == 0) {
if (first == 0) return;
rotate(begin + first - 1, begin + first, begin + last + 1);
first--;
last--;
}
// Move to top
else if (type == 1) {
rotate(begin, begin + first, begin + last + 1);
last = last - first;
first = 0;
}
// Move down
else if (type == 2) {
if (last + 1 == (int)styls.size()) return;
rotate(begin + first, begin + last + 1, begin + last + 2);
first++;
last++;
}
// Move to bottom
else if (type == 3) {
rotate(begin + first, begin + last + 1, styls.end());
first = styls.size() - (last - first + 1);
last = styls.size() - 1;
}
// Sort
else if (type == 4) {
// Get confirmation
if (storage) {
int res = wxMessageBox(_("Are you sure? This cannot be undone!"), _("Sort styles"), wxYES_NO | wxCENTER);
if (res == wxNO) return;
}
sort(styls.begin(), styls.end(), cmp_name());
first = 0;
last = 0;
}
}
示例5: operator
void operator()(Cont& c, long count) {
long cnt = count * 10;
if (cnt > c.size()) {
cout << "RemoveBack: not enough elements"
<< endl;
return;
}
for (long i = 0; i < cnt; i++)
c.pop_back();
}
示例6: push
inline std::enable_if_t<std::is_base_of<T, std::decay_t<U>>::value> push(U&& value) {
std::unique_lock<std::mutex> lock(mut);
// only add the value on the stack if there is room
data_cond.wait(lock, [this]{
return (data_queue.size() < capacity) || shutdownFlag;
});
data_queue.emplace(std::make_shared<
std::decay_t<U>> (std::forward<U>(value)));
data_cond.notify_one();
}
示例7: size
static size_type size(Cont const &cont) { return cont.size(); }
示例8: size
size_type size() const { return container.size(); }
示例9: check_empty
inline bool check_empty(const Cont &c)
{
return c.empty() && c.size() == 0 && c.begin() == c.end();
}
示例10: create_i_buffer
com_ptr<ID3D11Buffer> create_i_buffer(device_type device, UINT cpu_access_flags, D3D11_USAGE usage, const Cont& cont) {
return create_i_buffer(device, cpu_access_flags, usage, sizeof(Cont::value_type) * cont.size());
}
示例11: max
inline typename Cont::size_type max() const {
return not_prime.size()-1;
}