本文整理汇总了C++中Cont::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Cont::insert方法的具体用法?C++ Cont::insert怎么用?C++ Cont::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cont
的用法示例。
在下文中一共展示了Cont::insert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
iterator insert(value_type&& val) {
if (container.empty()) {
return container.insert(detail::adl_cend(container), val);
}
auto elementgreaterthanorequalto = std::lower_bound(detail::adl_cbegin(container), detail::adl_cend(container), val, std::ref(predicate));
return container.insert(elementgreaterthanorequalto, std::move(val));
}
示例2: insert
iterator insert(value_type&& val) {
if (container.empty()) {
return container.insert(cend(), val);
}
auto elementgreaterthanorequalto = std::lower_bound(cbegin(), cend(), val, std::ref(compare_predicate));
return container.insert(elementgreaterthanorequalto, std::move(val));
}
示例3: zip_var
auto zip_var(LastCont lastContainer) {
Cont<tuple<typename LastCont::value_type>, allocator<tuple<typename LastCont::value_type>>> result;
for_each(lastContainer.begin(), lastContainer.end(), [&](auto &content) {
result.insert(result.end(), make_tuple(content));
});
return result;
}
示例4: insert_back
void insert_back(Cont& c, long& avg, const int& num_op)
{
cout << "\nCounting..."
<< "time of " << num_op << " back_insert";
clock_t t = 0;
for(int j = 0; j < REPEAT_TEST; ++j)
{
c.push_back(0);
c.push_back(0);
auto it = c.end();
t = clock();
for (int i = 1; i <= num_op ; ++i)
{
it = c.end();
c.insert(it, i);
}
t = clock() - t;
avg += t;
c.clear();
}
avg /= REPEAT_TEST;
}
示例5: erase
bool erase(T t) {
ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
if (it == elements.end()) {
return false;
}
if (it->ub < t || it->lb > t) {
return false;
}
if (it->lb == t && it->ub == t) {
elements.erase(it);
--_size;
return true;
}
if (it->ub == t) {
--it->ub;
--_size;
return true;
}
if (it->lb == t) {
++it->lb;
--_size;
return true;
}
if (it->lb < t && it->ub > t) {
elements.insert(it + 1, interval(t + 1, it->ub));
it->ub = t - 1;
--_size;
return true;
}
assert(false && "interval_vector.erase() should never reach this place...");
return false;
}
示例6: insert
bool insert(T t) {
ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
if (it != elements.end() && t >= it->lb && t <= it->ub) {
return false;
}
ContIter pr = it - 1;
if (it != elements.begin() && pr->ub + 1 == t) {
++pr->ub;
if (it != elements.end() && pr->ub + 1 == it->lb) {
pr->ub = it->ub;
elements.erase(it);
}
}
else if (it != elements.end() && it->lb == t + 1) {
--it->lb;
if (it != elements.begin() && pr->ub + 1 == it->lb) {
pr->ub = it->ub;
elements.erase(it);
}
}
else {
elements.insert(it, interval(t));
}
++_size;
return true;
}
示例7: emplace
iterator emplace(Tn&&... argn) {
if (container.empty()) {
return container.insert(detail::adl_cend(container), std::forward<Tn>(argn)...);
}
auto elementgreaterthanorequalto = std::lower_bound(detail::adl_cbegin(container), detail::adl_cend(container), val, std::ref(predicate));
return container.emplace(elementgreaterthanorequalto, std::forward<Tn>(argn)...);
}
示例8: operator
void operator()(Cont& c, long count) {
typename Cont::iterator it;
long cnt = count / 10;
for (long i = 0; i < cnt; i++) {
// Must get the iterator every time to keep
// from causing an access violation with
// vector. Increment it to put it in the
// middle of the container:
it = c.begin();
it++;
c.insert(it, fs);
}
}
示例9: test_unordered_interface
void test_unordered_interface()
{
Cont c;
T* t = new T;
c.insert( t );
typename Cont::local_iterator i = c.begin( 0 );
typename Cont::const_local_iterator ci = i;
ci = c.cbegin( 0 );
i = c.end( 0 );
ci = c.cend( 0 );
typename Cont::size_type s = c.bucket_count();
s = c.max_bucket_count();
s = c.bucket_size( 0 );
s = c.bucket( *t );
float f = c.load_factor();
f = c.max_load_factor();
c.max_load_factor(f);
c.rehash(1000);
}
示例10: mock_cursor_data
void mock_cursor_data(Cont& data)
{
data.insert(test_data( 0, 0, 5,10, 8));
data.insert(test_data( 1, 1, 1, 4, 3));
data.insert(test_data( 3, 2, 0, 0, 1));
data.insert(test_data( 4, 3, 3, 3, 6));
data.insert(test_data( 9, 4, 2, 1, 4));
data.insert(test_data(10, 5, 4, 2, 7));
data.insert(test_data( 2, 6, 6, 9,10));
data.insert(test_data( 6, 7,10, 8,14));
data.insert(test_data(13, 8, 9, 7,13));
data.insert(test_data(27, 9, 7, 6,11));
data.insert(test_data(56,10, 8, 5,12));
}
示例11: replace_key
inline
bool replace_key (Cont& c,
const typename Cont::key_type& old_key,
const typename Cont::key_type& new_key)
{
typename Cont::iterator pos;
pos = c.find(old_key);
if (pos != c.end()) {
// insert new element with value of old element
c.insert(typename Cont::value_type(new_key,
pos->second));
// remove old element
c.erase(pos);
return true;
}
else {
// key not found
return false;
}
}
示例12: test_unordered_interface
void test_unordered_interface()
{
Cont c;
T* t = new T;
Key key = get_next_key( key );
c.insert( key, t );
typename Cont::local_iterator i = c.begin( 0 );
typename Cont::const_local_iterator ci = i;
ci = c.cbegin( 0 );
i = c.end( 0 );
ci = c.cend( 0 );
typename Cont::size_type s = c.bucket_count();
hide_warning(s);
s = c.max_bucket_count();
s = c.bucket_size( 0 );
s = c.bucket( key );
float f = c.load_factor();
f = c.max_load_factor();
c.max_load_factor(f);
c.rehash(1000);
}