本文整理汇总了C++中MapType类的典型用法代码示例。如果您正苦于以下问题:C++ MapType类的具体用法?C++ MapType怎么用?C++ MapType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MapType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
std::string LLEventDetail::listenerNameForCoroImpl(const void* self_id)
{
// First, if this coroutine was launched by LLCoros::launch(), find that name.
std::string name(LLCoros::instance().getNameByID(self_id));
if (! name.empty())
{
return name;
}
// Apparently this coroutine wasn't launched by LLCoros::launch(). Check
// whether we have a memo for this self_id.
typedef std::map<const void*, std::string> MapType;
static MapType memo;
MapType::const_iterator found = memo.find(self_id);
if (found != memo.end())
{
// this coroutine instance has called us before, reuse same name
return found->second;
}
// this is the first time we've been called for this coroutine instance
name = LLEventPump::inventName("coro");
memo[self_id] = name;
LL_INFOS("LLEventCoro") << "listenerNameForCoroImpl(" << self_id << "): inventing coro name '"
<< name << "'" << LL_ENDL;
return name;
}
示例2: main
int main(/*int argc, char *argv[]*/) {
ios::sync_with_stdio(false);
int n, m;
MapType data;
vector<unsigned> paths;
cin >> n >> m;
data.resize(n);
for (int i = 0; i < n; i++) {
data[i].resize(i + 1);
for (int j = 0; j <= i; j++) { cin >> data[i][j]; } // for
} // for
unsigned path;
unsigned end = 0U;
for (unsigned i = 0; i < n - 1; i++) { end = (end << 1) + 1U; } // for
for (path = 0U; path <= end; path++) { paths.push_back(path); } // for
for (auto p : paths) {
if (ComputePath(p, n, data, m)) {
PrintPath(p, n, data);
cout << endl;
}
} // foreach in paths
return 0;
} // function main
示例3: readFromMessage
int Location::readFromMessage(const MapType & msg)
{
try {
MapType::const_iterator I = msg.find("pos");
MapType::const_iterator Iend = msg.end();
if (I != Iend) {
const Element & pos = I->second;
if (pos.isList() && pos.List().size() == 3) {
m_pos.fromAtlas(pos);
} else {
log(ERROR, "Malformed POS data");
}
}
I = msg.find("orientation");
if (I != Iend) {
const Element & orientation = I->second;
if (orientation.isList() && orientation.List().size() == 4) {
m_orientation.fromAtlas(orientation);
} else {
log(ERROR, "Malformed ORIENTATION data");
}
}
}
catch (Atlas::Message::WrongTypeException&) {
log(ERROR, "Location::readFromMessage: Bad location data");
return -1;
}
return 0;
}
示例4: findInTable
typename MapType::const_iterator findInTable(const MapType& map, const std::wstring& name, const SourcePos& pos, const ErrorCode notFoundError, const ErrorCode misspelledError)
{
typename MapType::const_iterator it(map.find(name));
if (it == map.end())
{
const unsigned maxDist(3);
std::wstring bestName;
unsigned bestDist(std::numeric_limits<unsigned>::max());
for (typename MapType::const_iterator jt(map.begin()); jt != map.end(); ++jt)
{
const std::wstring thatName(jt->first);
const unsigned d(editDistance<std::wstring>(name, thatName, maxDist));
if (d < bestDist && d < maxDist)
{
bestDist = d;
bestName = thatName;
}
}
if (bestDist < maxDist)
throw TranslatableError(pos, misspelledError).arg(name).arg(bestName);
else
throw TranslatableError(pos, notFoundError).arg(name);
}
return it;
}
示例5: adjustRetentionTimes_
void adjustRetentionTimes_(MapType& map, const String& trafo_out,
bool first_file)
{
map.updateRanges();
TransformationDescription trafo;
if (first_file) // no transformation necessary
{
rt_offset_ = map.getMax()[0] + rt_gap_;
trafo.fitModel("identity");
}
else // subsequent file -> apply transformation
{
TransformationDescription::DataPoints points(2);
double rt_min = map.getMin()[0], rt_max = map.getMax()[0];
points[0] = make_pair(rt_min, rt_offset_);
rt_offset_ += rt_max - rt_min;
points[1] = make_pair(rt_max, rt_offset_);
trafo.setDataPoints(points);
trafo.fitModel("linear");
MapAlignmentTransformer::transformRetentionTimes(map, trafo, true);
rt_offset_ += rt_gap_;
}
if (!trafo_out.empty())
{
TransformationXMLFile().store(trafo_out, trafo);
}
}
示例6: main
int main() {
while (true) {
unsigned size;
vector<string> mapData;
size = RequireInput<unsigned>(">");
if (size == SIGNAL_EXIT) { break; }
cin.ignore();
for (unsigned i = 0; i != size; i++) { mapData.push_back(RequireInput<string>(">")); } // for
MapType map;
for (unsigned x = 0; x != size; x++) {
map.push_back(LineType());
for (unsigned y = 0; y != size; y++) {
switch (mapData[x][y]) {
case ElementSafe: map[x].push_back(ElementType::Safe); break;
case ElementWall: map[x].push_back(ElementType::Wall); break;
} // switch to mapData[x][y]
} // for
} // for
Output(GetMaxNumberOfCastles(map, size));
// PrintMap(map);
}
return 0;
} // function main
示例7: printMap
void printMap(MapType const& m)
{
int originX = 0;
int originY = 0;
int dx = 0;
int dy = 0;
m.boundingBox(originX, originY, dx, dy);
MapType::TileMap const& tiles = m.tileMap();
std::vector<char> bigMap(dx * dy, ' ');
MapType::TileMap::const_iterator first, last = tiles.end();
for (first = tiles.begin(); first != last; ++first) {
TileType& tile = *first->second;
for (unsigned int x = 0; x < TileType::TileSize; ++x) {
for (unsigned int y = 0; y < TileType::TileSize; ++y) {
int xIndex = x + tile.originX() - originX;
int yIndex = y + tile.originY() - originY;
bigMap[xIndex + dx * yIndex] = tile.cell(x, y).a;
}
}
}
int index = 0;
for (int y = originY; y < originY + dy; ++y) {
for (int x = originX; x < originX + dx; ++x) {
cout << bigMap[index] << flush;
++index;
}
cout << endl;
}
}
示例8: MapType
// Routine to compute optimal tic-tac-toe move.
int TicTacToe::chooseMove( Side s, int & bestRow, int & bestColumn,
int alpha, int beta, int depth )
{
Side opp; // The other side
int reply; // Value of opponent's reply
int dc; // Placeholder
int simpleEval; // Result of an immediate evaluation
Position thisPosition = board;
int value;
static const int TABLE_DEPTH = 5; // Max depth placed in Trans. table
if( ( simpleEval = positionValue( ) ) != UNCLEAR )
return simpleEval;
if( depth == 0 )
transpositions = MapType( ); // makeEmpty
else if( depth >= 3 && depth <= TABLE_DEPTH )
{
MapItr itr = transpositions.find( thisPosition );
if( itr != transpositions.end( ) )
return (*itr).second;
}
if( s == COMPUTER )
{
opp = HUMAN; value = alpha;
}
else
{
opp = COMPUTER; value = beta;
}
for( int row = 0; row < 3; row++ )
for( int column = 0; column < 3; column++ )
if( squareIsEmpty( row, column ) )
{
place( row, column, s );
reply = chooseMove( opp, dc, dc, alpha, beta, depth + 1 );
place( row, column, EMPTY );
if( s == COMPUTER && reply > value ||
s == HUMAN && reply < value )
{
if( s == COMPUTER )
alpha = value = reply;
else
beta = value = reply;
bestRow = row; bestColumn = column;
if( alpha >= beta )
goto Done; // Refutation
}
}
Done:
if( depth <= TABLE_DEPTH )
transpositions[ thisPosition ] = value;
return value;
}
示例9: GetItem
static inline typename MapType::mapped_type GetItem(const MapType& map, const typename MapType::key_type& key)
{
typename MapType::const_iterator mapIt = map.find(key);
if (mapIt != map.end())
return mapIt->second;
else
return typename MapType::mapped_type();
}
示例10: valueForKey
static typename MapType::MappedType valueForKey(const MapType& map, const typename MapType::KeyType& key)
{
typename MapType::const_iterator it = map.find(key);
if (it != map.end())
return it->second;
return defaultValueForKey<typename MapType::MappedType>(key);
}
示例11: dictAsElement
MapType CyPy_Element::dictAsElement(const Py::Dict& dict)
{
MapType map;
for (auto key : dict.keys()) {
map.emplace(key.str(), asElement(dict.getItem(key)));
}
return map;
}
示例12: test_addToMessage
void Admintest::test_addToMessage()
{
MapType data;
m_account->addToMessage(data);
ASSERT_NOT_EQUAL(data.find("character_types"), data.end());
ASSERT_EQUAL(data["character_types"], ListType());
}
示例13: streamMessageElement
void Encoder::streamMessageElement(const MapType& obj)
{
m_b.streamMessage();
MapType::const_iterator I;
for (I = obj.begin(); I != obj.end(); I++) {
mapElementItem((*I).first, (*I).second);
}
m_b.mapEnd();
}
示例14: listElementMapItem
void Encoder::listElementMapItem(const MapType& obj)
{
m_b.listMapItem();
MapType::const_iterator I;
for (I = obj.begin(); I != obj.end(); I++) {
mapElementItem(I->first, I->second);
}
m_b.mapEnd();
}
示例15: getRetentionTimes_
void MapAlignmentAlgorithmIdentification::getRetentionTimes_(
MapType & features, SeqToList & rt_data)
{
bool use_feature_rt = param_.getValue("use_feature_rt").toBool();
for (typename MapType::Iterator feat_it = features.begin();
feat_it != features.end(); ++feat_it)
{
if (use_feature_rt)
{
// find the peptide ID closest in RT to the feature centroid:
String sequence;
DoubleReal rt_distance = numeric_limits<DoubleReal>::max();
bool any_good_hit = false;
for (vector<PeptideIdentification>::iterator pep_it =
feat_it->getPeptideIdentifications().begin(); pep_it !=
feat_it->getPeptideIdentifications().end(); ++pep_it)
{
if (hasGoodHit_(*pep_it))
{
any_good_hit = true;
DoubleReal current_distance =
abs(double(pep_it->getMetaValue("RT")) - feat_it->getRT());
if (current_distance < rt_distance)
{
sequence = pep_it->getHits()[0].getSequence().toString();
rt_distance = current_distance;
}
}
}
if (any_good_hit)
rt_data[sequence] << feat_it->getRT();
}
else
{
getRetentionTimes_(feat_it->getPeptideIdentifications(), rt_data);
}
}
if (!use_feature_rt && param_.getValue("use_unassigned_peptides").toBool())
{
getRetentionTimes_(features.getUnassignedPeptideIdentifications(),
rt_data);
}
// remove duplicates (can occur if a peptide ID was assigned to several
// features due to overlap or annotation tolerance):
for (SeqToList::iterator rt_it = rt_data.begin();
rt_it != rt_data.end(); ++rt_it)
{
DoubleList & rt_values = rt_it->second;
sort(rt_values.begin(), rt_values.end());
DoubleList::iterator it = unique(rt_values.begin(), rt_values.end());
rt_values.resize(it - rt_values.begin());
}
}