当前位置: 首页>>代码示例>>C++>>正文


C++ MapType类代码示例

本文整理汇总了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;
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:25,代码来源:lleventcoro.cpp

示例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
开发者ID:riteme,项目名称:test,代码行数:28,代码来源:main.cpp

示例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;
}
开发者ID:alriddoch,项目名称:cyphesis,代码行数:29,代码来源:Location.cpp

示例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;
	}
开发者ID:antoinealb,项目名称:aseba,代码行数:25,代码来源:identifier-lookup.cpp

示例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);
   }
 }
开发者ID:chahuistle,项目名称:OpenMS,代码行数:27,代码来源:FileMerger.cpp

示例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
开发者ID:riteme,项目名称:test,代码行数:28,代码来源:main.cpp

示例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;
  }
}
开发者ID:ekpneo,项目名称:soraCore,代码行数:34,代码来源:tiledMapTest.cpp

示例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;
}
开发者ID:anilpawar-pd,项目名称:Eclipse-for-Java,代码行数:60,代码来源:TicTac.cpp

示例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();
}
开发者ID:cleanrock,项目名称:pr-downloader,代码行数:8,代码来源:optionswrapper.cpp

示例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);
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:8,代码来源:WebPreferencesStore.cpp

示例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;
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:8,代码来源:CyPy_Element.cpp

示例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());
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:9,代码来源:Admintest.cpp

示例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();
}
开发者ID:bregma,项目名称:atlas-cpp,代码行数:9,代码来源:MEncoder.cpp

示例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();
}
开发者ID:bregma,项目名称:atlas-cpp,代码行数:9,代码来源:MEncoder.cpp

示例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());
    }
  }
开发者ID:aiche,项目名称:open-ms-mirror,代码行数:57,代码来源:MapAlignmentAlgorithmIdentification.C


注:本文中的MapType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。