本文整理汇总了C++中set_type::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ set_type::erase方法的具体用法?C++ set_type::erase怎么用?C++ set_type::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set_type
的用法示例。
在下文中一共展示了set_type::erase方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Let an object un-register its existence
void
object_registrar::unregister_object_imp
(
object_id obj
)
{
set_type::iterator const i = db_.find( obj );
if ( i != db_.end() )
{
db_.erase( i );
#if CONTROL_EXTRA_PRINTING
std::cout << "Unregistered " << obj << '.' << std::endl;
#endif
}
else
{
overkilled_.push_back( obj );
#if CONTROL_EXTRA_PRINTING
std::cout << "Attempted to unregister a non-existant " << obj
<< '.' << std::endl;
#endif
}
}
示例2: erase
size_type erase (const key_type& k) {
if (k.first < k.second) {
if (empty ()) {
return 0;
}
iterator pos = find_first_intersect (k);
if (pos == end ()) {
return 0;
}
const Key alpha = pos->first;
const Key beta = std::min (pos->second, k.first);
Key delta = pos->second;
size_type count = 0;
while (pos != m_set.end () && intersect (*pos, k)) {
delta = pos->second;
m_set.erase (pos++);
++count;
}
insert (std::make_pair (alpha, beta));
insert (std::make_pair (k.second, delta));
return count;
}
return 0;
}
示例3: make_pair
std::pair<iterator, bool>
insert (const value_type& x) {
if (x.first < x.second) {
if (empty ()) {
return m_set.insert (x);
}
iterator pos = find_first_touch (x);
if (pos == end ()) {
//nothing intersects x
return m_set.insert (x);
}
const Key alpha = std::min (x.first, pos->first);
Key beta = pos->second;
while (pos != m_set.end () && touch (*pos, x)) {
beta = pos->second;
m_set.erase (pos++);
}
beta = std::max (beta, x.second);
return m_set.insert (std::make_pair (alpha, beta));
}
return std::make_pair (m_set.end (), false);
}
示例4: unregisterWith
inline
Size Observer::unregisterWith(const ext::shared_ptr<Observable>& h) {
boost::lock_guard<boost::recursive_mutex> lock(mutex_);
if (h) {
QL_REQUIRE(proxy_, "unregister called without a proxy");
h->unregisterObserver(proxy_);
}
return observables_.erase(h);
}
示例5: insert
//-----------------------------------------------------------------//
handle_type insert(const T& st) {
handle_type h;
if(erase_set_.empty()) {
h = static_cast<handle_type>(array_.size());
array_.push_back(st);
} else {
set_it it = erase_set_.begin();
h = *it;
array_[h] = st;
erase_set_.erase(it);
}
return h;
}
示例6: create
//-----------------------------------------------------------------//
handle_type create() {
handle_type h;
if(erase_set_.empty()) {
if(current_ < limit_) {
h = current_;
++current_;
} else {
current_ = limit_ - 1;
h = 0;
}
} else {
set_it it = erase_set_.begin();
h = *it;
erase_set_.erase(it);
}
return h;
}
示例7: unregisterDeferredObserver
inline void ObservableSettings::unregisterDeferredObserver(
const ext::shared_ptr<Observer::Proxy>& o) {
deferredObservers_.erase(o);
}
示例8: optimize
/**
* Moore's algorithm for DFA state minimization. Identifies all the
* indistinguishable subsets of
* DFA states and replaces them with a single state.
*/
void optimize()
{
// Compilers: Principles, Techniques and Tools SE, page 182
std::unordered_set<set_type, dfa_set_hash, dfa_set_eq> Gamma, newGamma;
std::unordered_map<node_type *, const set_type *> Map, newMap;
set_type newG;
// Create the initial partition - to accepting and non-accepting states
Gamma.insert(_nodes);
bool initialPartition = true;
// Refine partitions until there are no more changes.
while (true)
{
for (auto G : Gamma) // Copy
{
while (!G.empty())
{
newG.clear();
node_type* pivot = nullptr;
for (auto it = G.begin(); it != G.end();)
{
bool equiv;
if (pivot == nullptr)
pivot = *it;
// Initial partition is made by grouping all the terminal states
// emiting the same token type (all non-terminals also together).
if (initialPartition)
equiv = (pivot->terminal() == (*it)->terminal()) &&
(pivot->get_terminal() == (*it)->get_terminal());
else
equiv = check_equivalence(pivot, *it, Map);
if (equiv)
{
newG.insert(*it);
G.erase(it++);
}
else
{
++it;
}
}
auto subset = &*newGamma.insert(newG).first;
for (auto it = newG.begin(); it != newG.end(); ++it)
{
newMap.emplace(*it, subset);
}
}
}
initialPartition = false;
if (newGamma.size() == Gamma.size())
break;
else
{
newGamma.swap(Gamma);
newMap.swap(Map);
newGamma.clear();
newMap.clear();
}
}
set_type dead_states;
_initial = *newMap.at(_initial)->begin();
for (auto& node : _nodes)
{
for (auto& transitions : node->transitions)
{
auto& equiv_class = *newMap.at(transitions.next);
auto it = equiv_class.begin();
transitions.next = *it;
while (++it != equiv_class.end())
{
dead_states.insert(*it);
}
}
}
for (auto& node : dead_states)
{
_nodes.erase(node);
delete node;
}
aggregate();
}