本文整理汇总了C++中vector_type::end方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_type::end方法的具体用法?C++ vector_type::end怎么用?C++ vector_type::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_type
的用法示例。
在下文中一共展示了vector_type::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool operator==(box const &b2) const
{
return
std::equal(m_lower.begin(), m_lower.end(), b2.m_lower.begin())
&&
std::equal(m_upper.begin(), m_upper.end(), b2.m_upper.begin());
}
示例2: linear_sort_streamed
void linear_sort_streamed(vector_type& input, vector_type& output)
{
unsigned_type sum1 = checksum(input);
stxxl::stats_data stats_begin(*stxxl::stats::get_instance());
double start = stxxl::timestamp();
typedef stxxl::stream::streamify_traits<vector_type::iterator>::stream_type input_stream_type;
input_stream_type input_stream = stxxl::stream::streamify(input.begin(), input.end());
typedef cmp_less_key comparator_type;
comparator_type cl;
typedef stxxl::stream::sort<input_stream_type, comparator_type, block_size> sort_stream_type;
sort_stream_type sort_stream(input_stream, cl, run_size);
vector_type::iterator o = stxxl::stream::materialize(sort_stream, output.begin(), output.end());
STXXL_CHECK(o == output.end());
double stop = stxxl::timestamp();
std::cout << stxxl::stats_data(*stxxl::stats::get_instance()) - stats_begin;
unsigned_type sum2 = checksum(output);
std::cout << sum1 << " ?= " << sum2 << std::endl;
if (sum1 != sum2)
STXXL_MSG("WRONG DATA");
STXXL_CHECK(stxxl::is_sorted<vector_type::const_iterator>(output.begin(), output.end(), comparator_type()));
std::cout << "Linear sorting streamed took " << (stop - start) << " seconds." << std::endl;
}
示例3: get
const TValue get(const TId id) const final {
const element_type element {
id,
osmium::index::empty_value<TValue>()
};
const auto result = std::lower_bound(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
return a.first < b.first;
});
if (result == m_vector.end() || result->first != id) {
not_found_error(id);
} else {
return result->second;
}
}
示例4: checksum
unsigned_type checksum(vector_type& input)
{
unsigned_type sum = 0;
for (vector_type::const_iterator i = input.begin(); i != input.end(); ++i)
sum += (unsigned_type)((*i).m_key);
return sum;
}
示例5: get_noexcept
TValue get_noexcept(const TId id) const noexcept final {
const auto result = find_id(id);
if (result == m_vector.end() || result->first != id) {
return osmium::index::empty_value<TValue>();
}
return result->second;
}
示例6: get
TValue get(const TId id) const final {
const auto result = find_id(id);
if (result == m_vector.end() || result->first != id) {
throw osmium::not_found{id};
}
return result->second;
}
示例7: lower_bound
typename vector_type::const_iterator find_id(const TId id) const noexcept {
const element_type element {
id,
osmium::index::empty_value<TValue>()
};
return std::lower_bound(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
return a.first < b.first;
});
}
示例8: equal_range
std::pair<iterator, iterator> get_all(const TId id) {
const element_type element {
id,
osmium::index::empty_value<TValue>()
};
return std::equal_range(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
return a.first < b.first;
});
}
示例9: super
decorated_tuple(cow_pointer_type d, const vector_type& v)
: super(tuple_impl_info::statically_typed)
, m_decorated(std::move(d)), m_mapping(v) {
# ifdef CPPA_DEBUG
const cow_pointer_type& ptr = m_decorated; // prevent detaching
# endif
CPPA_REQUIRE(ptr->size() >= sizeof...(ElementTypes));
CPPA_REQUIRE(v.size() == sizeof...(ElementTypes));
CPPA_REQUIRE(*(std::max_element(v.begin(), v.end())) < ptr->size());
}
示例10: do_filter
void do_filter(const vector_type& src, vector_type& dest)
{
typedef regex_iterator<const Ch*, Ch, Tr> iterator;
if (src.empty())
return;
iterator first(&src[0], &src[0] + src.size(), re_, flags_);
iterator last;
const Ch* suffix = 0; // Prevent GCC 2.95 warning.
for (; first != last; ++first) {
dest.insert( dest.end(),
first->prefix().first,
first->prefix().second );
string_type replacement = replace_(*first);
dest.insert( dest.end(),
replacement.begin(),
replacement.end() );
suffix = first->suffix().first;
}
dest.insert(dest.end(), suffix, &src[0] + src.size());
}
示例11: linear_sort_normal
void linear_sort_normal(vector_type& input)
{
unsigned_type sum1 = checksum(input);
stxxl::stats_data stats_begin(*stxxl::stats::get_instance());
double start = stxxl::timestamp();
stxxl::sort(input.begin(), input.end(), cmp_less_key(), run_size);
double stop = stxxl::timestamp();
std::cout << stxxl::stats_data(*stxxl::stats::get_instance()) - stats_begin;
unsigned_type sum2 = checksum(input);
std::cout << sum1 << " ?= " << sum2 << std::endl;
STXXL_CHECK(stxxl::is_sorted<vector_type::const_iterator>(input.begin(), input.end()));
std::cout << "Linear sorting normal took " << (stop - start) << " seconds." << std::endl;
}
示例12: eval
boost::logic::tribool eval(const partial_assignments_type& phi) {
typedef std::set<value_type> set_type;
set_type collected_values;
typedef typename set_type::size_type size_type;
size_type set_size = 0;
typedef typename vector_type::const_iterator vector_iterator;
const vector_iterator& end(variable_vector.end());
for (vector_iterator i = variable_vector.begin(); i != end; ++i) {
const domain_type& D(phi(*i));
if (D.size() == 0) return false;
if (D.size() == 1) {
collected_values.insert(*(i -> second.begin()));
if (collected_values == set_size++)
return false;
}
}
assert(set_size == collected_values.size());
if (set_size == variable_vector.size())
return true;
else
return boost::logic::indeterminate;
}
示例13: timer
void lattice<dimension, float_type>::fcc(
position_iterator first, position_iterator last
, vector_type const& length, vector_type const& offset
)
{
typedef fixed_vector<unsigned int, dimension> index_type;
typedef close_packed_lattice<vector_type, index_type> lattice_type;
scoped_timer_type timer(runtime_.set);
LOG_TRACE("generating fcc lattice for " << last - first << " particles, box: " << length << ", offset: " << offset);
size_t npart = last - first;
double u = lattice_type(1).size();
double V = accumulate(length.begin(), length.end(), 1., multiplies<double>()) / ceil(npart / u);
double a = pow(V, 1. / dimension);
index_type n(length / a);
while (npart > u * accumulate(n.begin(), n.end(), 1, multiplies<unsigned int>())) {
vector_type t;
for (size_t i = 0; i < dimension; ++i) {
t[i] = length[i] / (n[i] + 1);
}
typename vector_type::iterator it = max_element(t.begin(), t.end());
a = *it;
// recompute n to preserve aspect ratios of box, ensure that
// no compoment decreases and that at least one component
// is incremented
index_type m = n;
n = element_max(m, static_cast<index_type>(length / a));
if (m == n) {
n += index_type(1);
}
}
LOG("placing particles on fcc lattice: a = " << a);
LOG_DEBUG("number of fcc unit cells: " << n);
unsigned int N = static_cast<unsigned int>(
u * accumulate(n.begin(), n.end(), 1, multiplies<unsigned int>())
);
if (N > npart) {
LOG_WARNING("lattice not fully occupied (" << N << " sites)");
}
// insert a vacancy every 'skip' sites
unsigned int skip = (N - npart) ? static_cast<unsigned int>(ceil(static_cast<double>(N) / (N - npart))) : 0;
if (skip) {
LOG_TRACE("insert a vacancy at every " << skip << "th site");
}
lattice_type const lattice(n);
size_t i = 0;
for (position_iterator r_it = first; r_it != last; ++r_it, ++i) {
// skip vacant lattice points
if (skip && i % skip == skip - 1) {
++i;
}
vector_type& r = *r_it = lattice(i);
// scale by lattice constant
r *= a;
// shift origin of lattice to offset
r += offset;
}
assert(i <= N);
LOG_DEBUG("number of particles inserted: " << last - first);
}
示例14: sort
void sort() override final {
std::sort(m_vector.begin(), m_vector.end());
}
示例15: insert
//
// This function inserts "Clones" into the
// the view.
//
// We need to pass the first argument
// as a non-const reference to be able to store
// 'T*' instead of 'const T*' objects. Alternatively,
// we might change the declaration of the 'view_type'
// to
// typedef boost::ptr_vector<const photon,boost::view_clone_manager>
// view_type; ^^^^^^
//
void insert( vector_type& from, view_type& to )
{
to.insert( to.end(),
from.begin(),
from.end() );
}