本文整理汇总了C++中TypeSet::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeSet::insert方法的具体用法?C++ TypeSet::insert怎么用?C++ TypeSet::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSet
的用法示例。
在下文中一共展示了TypeSet::insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getGreatestCommonSubtypes
TypeSet getGreatestCommonSubtypes(const TypeSet& set) {
// handle the empty set
if (set.empty()) return set;
// handle the all set => empty set (since no common sub-type)
if (set.isAll()) return TypeSet();
TypeSet res;
auto it = set.begin();
res.insert(*it);
++it;
// refine sub-set step by step
for(;it != set.end(); ++it) {
TypeSet tmp;
for(const Type& cur : res) {
tmp.insert(getGreatestCommonSubtypes(cur, *it));
}
res = tmp;
}
// done
return res;
}
示例2: visit
void visit(const Type& type) const {
if (isSubtypeOf(type, b)) {
res.insert(type);
} else {
TypeVisitor<void>::visit(type);
}
}
示例3: getLeastCommonSupertypes
TypeSet getLeastCommonSupertypes(const Type& a, const Type& b) {
// make sure they are in the same type environment
assert(a.getTypeEnvironment().isType(a) && a.getTypeEnvironment().isType(b));
// if they are equal it is easy
if (a == b) {
return TypeSet(a);
}
// equally simple - check whether one is a sub-type of the other
if (isSubtypeOf(a,b)) {
return TypeSet(b);
}
if (isSubtypeOf(b,a)) {
return TypeSet(a);
}
// harder: no obvious relation => hard way
TypeSet superTypes;
TypeSet all = a.getTypeEnvironment().getAllTypes();
for(const Type& cur : all) {
if (isSubtypeOf(a, cur) && isSubtypeOf(b, cur)) {
superTypes.insert(cur);
}
}
// filter out non-least super types
TypeSet res;
for(const Type& cur : superTypes) {
bool least = !any_of(superTypes, [&](const Type& t) {
return t != cur && isSubtypeOf(t, cur);
});
if (least) res.insert(cur);
}
return res;
}
示例4: optimize
/**
* Run an optimization step.
*/
size_t OptimizationImpl::optimize(Scope& scope) {
TypeList to_optimize;
single_impls->get_interfaces(to_optimize);
for (auto intf : to_optimize) {
auto& intf_data = single_impls->get_single_impl_data(intf);
TRACE(INTF, 3, "(OPT) %s => %s\n", SHOW(intf), SHOW(intf_data.cls));
if (intf_data.is_escaped()) continue;
auto escape = can_optimize(intf, intf_data);
if (escape != EscapeReason::NO_ESCAPE) {
single_impls->escape_interface(intf, escape);
continue;
}
do_optimize(intf, intf_data);
optimized.insert(intf);
}
// make a new scope deleting all single impl interfaces
Scope new_scope;
for (auto cls : scope) {
if (optimized.find(cls->get_type()) != optimized.end()) continue;
new_scope.push_back(cls);
}
scope.swap(new_scope);
return optimized.size();
}
示例5: getAllTypes
TypeSet TypeEnvironment::getAllTypes() const {
TypeSet res;
for(const auto& cur : types) res.insert(*cur.second);
return res;
}
示例6: process
bool CalculateAmplitudes::process() {
//_ui.btnOK->setEnabled(false);
_processors.clear();
_ui.table->setRowCount(0);
Core::TimeWindow acTimeWindow;
if ( !_origin || (_recomputeAmplitudes && !_thread) )
return false;
if ( _amplitudeTypes.empty() )
return false;
_timeWindow = Core::TimeWindow();
/*
TypeSet wantedAmpTypes;
wantedAmpTypes.insert("MLv");
wantedAmpTypes.insert("mb");
wantedAmpTypes.insert("mB");
wantedAmpTypes.insert("Mwp");
try {
vector<string> amps = SCApp->configGetStrings("amplitudes");
wantedAmpTypes.clear();
wantedAmpTypes.insert(amps.begin(), amps.end());
}
catch (...) {}
*/
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
if ( _thread )
_thread->connect();
typedef pair<PickCPtr, double> PickStreamEntry;
// Typedef a pickmap that maps a streamcode to a pick
typedef map<string, PickStreamEntry> PickStreamMap;
// This map is needed to find the earliest P pick of
// a certain stream
PickStreamMap pickStreamMap;
for ( size_t i = 0; i < _origin->arrivalCount(); ++i ) {
Arrival *ar = _origin->arrival(i);
double weight = 1.;
try {
weight = ar->weight();
}
catch (Seiscomp::Core::ValueException) {}
if ( Util::getShortPhaseName(ar->phase().code()) != 'P' || weight < 0.5 ) {
continue;
}
Pick *pick = Pick::Find(ar->pickID());
if ( !pick ) {
// cerr << " - Skipping arrival " << i << " -> no pick found" << endl;
continue;
}
double dist = -1;
try {
dist = ar->distance();
}
catch ( Core::ValueError &e ) {
try {
Client::StationLocation loc;
double azi1, azi2;
loc = Client::Inventory::Instance()->stationLocation(pick->waveformID().networkCode(), pick->waveformID().stationCode(), pick->time().value());
Math::Geo::delazi(loc.latitude, loc.longitude, _origin->latitude(), _origin->longitude(), &dist, &azi1, &azi2);
}
catch ( Core::GeneralException &e ) {}
}
DataModel::WaveformStreamID wfid = pick->waveformID();
// Strip the component code because every AmplitudeProcessor
// will use its own component to pick the amplitude on
wfid.setChannelCode(wfid.channelCode().substr(0,2));
string streamID = waveformIDToStdString(wfid);
PickStreamEntry &e = pickStreamMap[streamID];
// When there is already a pick registered for this stream which has
// been picked earlier, ignore the current pick
if ( e.first && e.first->time().value() < pick->time().value() )
continue;
e.first = pick;
e.second = dist;
}
for ( PickStreamMap::iterator it = pickStreamMap.begin(); it != pickStreamMap.end(); ++it ) {
//.........这里部分代码省略.........