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


C++ MapT类代码示例

本文整理汇总了C++中MapT的典型用法代码示例。如果您正苦于以下问题:C++ MapT类的具体用法?C++ MapT怎么用?C++ MapT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MapT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: key_set

std::set<typename MapT::key_type> key_set(const MapT& m) {
    std::set<typename MapT::key_type> answer;
    for (auto it = m.begin(); it != m.end(); ++it) {
        answer.insert(it->first);
    }
    return answer;
}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:7,代码来源:simple_tools.hpp

示例2: value_set

std::set<typename MapT::mapped_type> value_set(const MapT& m) {
    std::set<typename MapT::mapped_type> answer;
    for (auto it = m.begin(); it != m.end(); ++it) {
        answer.insert(it->second);
    }
    return answer;
}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:7,代码来源:simple_tools.hpp

示例3: assert

double
Note2FreqTable::operator[](string str) const
{
    MapT::const_iterator iter = m_rep.find(str);
    assert(iter != m_rep.end());
    return iter->second;
}
开发者ID:strnbrg59,项目名称:stuff,代码行数:7,代码来源:note.cpp

示例4: load_and_init_with_map

static void load_and_init_with_map(const char* file, double* cpu_times, MapT& M)
{
   FILE* f = fopen(file,"r");
   if(f == NULL){
      fprintf(stderr, "Could not open %s file: %s", file, strerror(errno));
      exit(-1);
   }

   double nanosec;
   char ops[48];
   char line[512];
   std::string tmp = "";
   while(fgets(line,sizeof(line),f)){
      unsigned op;
      if (sscanf(line, "%47[^:]:\t%lf nanoseconds", ops, &nanosec) == 2) {
        tmp = ops;
        auto ite = M.find(ops);
        if (ite != M.end()) {
          op = ite->second;
          cpu_times[op] = nanosec;
        } else
          continue;
      }
   }
   fclose(f);
}
开发者ID:LGZ-T,项目名称:llvm-prof,代码行数:26,代码来源:TimingSource.cpp

示例5: DSF

void DSF(TMap const & maze,
         MapKeyT const & cur, MapKeyT const & prev, Cell const & target,
         MapT & data, vector<vector<int>> const & bonuses)
{
    bool IsOpposite = GetOppositeDirection(prev.second) == cur.second;
    double to_add = (IsOpposite ? 3 : 1);
    if (bonuses[cur.first.m_x][cur.first.m_y] == 1)
        to_add -= 0.5;
    
    bool need_update = data.count(cur) == 0;
    need_update |= data[cur].first > data[prev].first + to_add;
    if (need_update)
    {
        double prev_dist = data.count(prev) == 0 ? 0 : data[prev].first;
        data[cur] = {prev_dist + to_add, prev};
    }
    if (cur.first == target)
        return;
    if (need_update)
    {
        if (CanPass(maze, cur.first, cur.second))
            DSF(maze, {cur.first.GetNeibor(cur.second), cur.second}, cur, target, data, bonuses);
        for (auto const & dir: AllDirections())
            if (CanPass(maze, cur.first, dir))
                DSF(maze, {cur.first.GetNeibor(dir), dir}, cur, target, data, bonuses);
    }
}
开发者ID:sergey-pisarchik,项目名称:AICup-2015,代码行数:27,代码来源:PathUtils.cpp

示例6: find_nearest

typename MapT::const_iterator find_nearest(MapT const& m, typename MapT::key_type const& query, typename MapT::key_type const& tolerance)
{
    typename MapT::const_iterator cur, min, max, best;

    min = m.lower_bound(query - tolerance);
    max = m.lower_bound(query + tolerance);

    if (min == m.end() || fabs(query - min->first) > tolerance)
        return m.end();
    else if (min == max)
        return min;
    else
        best = min;

    double minDiff = fabs(query - best->first);
    for (cur = min; cur != max; ++cur)
    {
        double curDiff = fabs(query - cur->first);
        if (curDiff < minDiff)
        {
            minDiff = curDiff;
            best = cur;
        }
    }
    return best;
}
开发者ID:lgatto,项目名称:proteowizard,代码行数:26,代码来源:SpectrumList_3D_Test.cpp

示例7: GetClosestPath

vector<Cell> GetClosestPath(const model::World& world,
                            Cell const & start, Direction const start_dir, Cell const & finish, Game const & game)
{
    
    static map<cashe_key, vector<Cell> > cacshe;
    static int bonus_hash = 0;
    int bonus_hash_cur = 0;
    auto const & map = world.getTilesXY();
    vector<vector<int>> bonuses(map.size(), vector<int>(map[0].size(), 0));
    for (Bonus const & bonus: world.getBonuses())
    {
        bonus_hash_cur += bonus.getX() * bonus.getX() + bonus.getY() * bonus.getY();
        auto bonus_cell= GetCell(bonus, game);
        bonuses[bonus_cell.m_x][bonus_cell.m_y] = (bonus.getType() == PURE_SCORE || bonus.getType() == REPAIR_KIT) ? 1 : 0;
    }
    if (bonus_hash !=  bonus_hash_cur)
    {
        bonus_hash = bonus_hash_cur;
        cacshe.clear();
    }
    
    
    
    cashe_key ck = {start, start_dir, finish};
    if (cacshe.count(ck) == 1)
        return cacshe[ck];
    
    MapT data;
    DSF(world.getTilesXY(), {start, start_dir}, {start, start_dir}, finish, data, bonuses);
    //    PrintMap(world.getTilesXY(), data);
    
    vector<Cell> res;
    int const INF = 1000000;
    int best = INF;
    MapKeyT cur = {finish, LEFT};
    for (auto dir: AllDirections())
    {
        if (data.count({finish,dir}) == 0)
            continue;
        if (data[{finish,dir}].first < best)
        {
            best = data[{finish,dir}].first;
            cur = {finish,dir};
        }
        
    }
    if (best == INF)
        return res;
    
    
    while (cur.first != start)
    {
        res.push_back(cur.first);
        cur = data[cur].second;
    }
    res.push_back(start);
    reverse(res.begin(), res.end());
    cacshe[ck] = res;
    return res;
}
开发者ID:sergey-pisarchik,项目名称:AICup-2015,代码行数:60,代码来源:PathUtils.cpp

示例8: map_processor_index

inline index_type
map_processor_index(MapT const& map, processor_type pid)
{
    for (index_type i=0; i<map.processor_set().size(); ++i)
        if (map.processor_set().get(i) == pid)
            return i;
    return no_index;
}
开发者ID:somaproject,项目名称:thirdparty-packages,代码行数:8,代码来源:copy.cpp

示例9: BuildPalette

void wxsItemEditor::BuildPalette(wxNotebook* Palette)
{
    Palette->DeleteAllPages();
    bool AllowNonXRCItems = (m_Data->GetPropertiesFilter() & flSource);

    // First we need to split all widgets into groups
    // it will be done using multimap (map of arrays)

    MapT Map;

    for ( const wxsItemInfo* Info = wxsItemFactory::GetFirstInfo(); Info; Info = wxsItemFactory::GetNextInfo() )
    {
        if ( !Info->Category.empty() )
        {
            Map[Info->Category].Add(Info);
        }
    }

    for ( MapT::iterator i = Map.begin(); i!=Map.end(); ++i )
    {
        wxScrolledWindow* CurrentPanel = new wxScrolledWindow(Palette,-1,wxDefaultPosition,wxDefaultSize,0/*wxALWAYS_SHOW_SB|wxHSCROLL*/);
        CurrentPanel->SetScrollRate(1,0);
        Palette->AddPage(CurrentPanel,i->first);
        wxSizer* RowSizer = new wxBoxSizer(wxHORIZONTAL);

        ItemsT& Items = i->second;
        Items.Sort(PrioritySort);

        for ( size_t j=Items.Count(); j-->0; )
        {
            const wxsItemInfo* Info = Items[j];
            const wxBitmap& Icon = ( PalIconSize() == 16L ) ? Info->Icon16 : Info->Icon32;

            if ( AllowNonXRCItems || Info->AllowInXRC )
            {
                wxWindow* Btn;
                if ( Icon.Ok() )
                {
                    Btn = new wxBitmapButton(CurrentPanel,-1,Icon,
                              wxDefaultPosition,wxDefaultSize,wxBU_AUTODRAW,
                              wxDefaultValidator, Info->ClassName);
                    RowSizer->Add(Btn,0,wxALIGN_CENTER);
                }
                else
                {
                    Btn = new wxButton(CurrentPanel,-1,Info->ClassName,
                              wxDefaultPosition,wxDefaultSize,0,
                              wxDefaultValidator,Info->ClassName);
                    RowSizer->Add(Btn,0,wxGROW);
                }
                Btn->SetToolTip(Info->ClassName);
            }
        }
        CurrentPanel->SetSizer(RowSizer);
        RowSizer->SetVirtualSizeHints(CurrentPanel);
    }
}
开发者ID:stahta01,项目名称:EmBlocks,代码行数:57,代码来源:wxsitemeditor.cpp

示例10: show_map_contents

void show_map_contents(OStreamT& os, MapT& m, const std::string& title)
{
  os<< "<h3>" << title << "</h3>";
  
  if (m.empty())
    os<< "NONE<br />";
  else
    for (typename MapT::const_iterator i = m.begin(); i != m.end(); ++i)
      os<< "<b>" << i->first << "</b> = <i>" 
                 << i->second << "</i><br />";
}
开发者ID:aldot,项目名称:cgi,代码行数:11,代码来源:main.cpp

示例11: sort

void
Module::process_f_lit_map(MapT& map, vector<LitT>& vec)
{
    vec.assign(map.begin(), map.end());
    sort(vec.begin(), vec.end(), [](const LitT& lhs, const LitT& rhs) { return lhs.second > rhs.second; });
    size_t new_size = vec.size();
    for (; new_size > 0 && vec[new_size - 1].second <= 3; new_size--)
        map.erase(vec[new_size - 1].first);
    vec.resize(new_size);
    for (size_t i = 0; i < vec.size(); i++)
        map[vec[i].first] = static_cast<uint32_t>(i);
}
开发者ID:MikeHolman,项目名称:postorder-polyfill-prototype,代码行数:12,代码来源:Module.cpp

示例12: map_values

std::vector<typename MapT::mapped_type> map_values(MapT const& m, KeyIterT key_first, KeyIterT key_last)
{
	std::vector<typename MapT::mapped_type> res;

	while (key_first != key_last)
	{
		if (m.count(*key_first) > 0)
		{
			res.push_back(m.at(*key_first));
		}

		++key_first;
	}
	return res;
}
开发者ID:sguazt,项目名称:dcsxx-commons,代码行数:15,代码来源:map.hpp

示例13:

bool
Cstore::VarRef::getValue(string& value, vtw_type_e& def_type)
{
  vector<string> result;
  MapT<string, bool> added;
  def_type = ERROR_TYPE;
  for (size_t i = 0; i < _paths.size(); i++) {
    if (_paths[i].first.size() == 0) {
      // empty path
      continue;
    }
    if (added.find(_paths[i].first.back()) != added.end()) {
      // already added
      continue;
    }
    if (_paths[i].second == ERROR_TYPE
        && !_cstore->cfgPathExists(_paths[i].first, _active)) {
      // path doesn't exist => empty string
      added[""] = true;
      result.push_back("");
      continue;
    }
    if (_paths[i].second != ERROR_TYPE) {
      // set def_type. all types should be the same if multiple entries exist.
      def_type = _paths[i].second;
    }
    added[_paths[i].first.back()] = true;
    result.push_back(_paths[i].first.back());
  }
  if (result.size() == 0) {
    // got nothing
    return false;
  }
  if (result.size() > 1 || def_type == ERROR_TYPE) {
    /* if no type is available or we are returning "joined" multiple values,
     * treat it as text type.
     */
    def_type = TEXT_TYPE;
  }
  value = "";
  for (size_t i = 0; i < result.size(); i++) {
    if (i > 0) {
      value += " ";
    }
    value += result[i];
  }
  return true;
}
开发者ID:beamerblvd,项目名称:vyatta-cfg,代码行数:48,代码来源:cstore-varref.cpp

示例14: save

    //! @internal
    template <class Archive, class MapT> inline
    void save( Archive & ar, MapT const & map )
    {
      ar( make_size_tag( static_cast<size_type>(map.size()) ) );

      for( const auto & i : map )
        ar( make_map_item(i.first, i.second) );
    }
开发者ID:OlivierLi,项目名称:libclsph,代码行数:9,代码来源:unordered_map.hpp

示例15: next_proton

typename MapT::const_iterator next_proton(typename MapT::const_iterator& iter_, const MapT& object)
{
    while(   iter_ != object.end() 
          && (*iter_).second == identity_element<typename MapT::codomain_type>::value())
        ++iter_;

    return iter_;
}
开发者ID:imos,项目名称:icfpc2015,代码行数:8,代码来源:map_algo.hpp


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