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;
}
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;
}
Пример #3
0
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);
    }
}
Пример #4
0
Файл: main.cpp Проект: aldot/cgi
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 />";
}
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);
}
Пример #6
0
bool lexicographical_distinct_equal(const MapT& left, const MapT& right)
{
    if(&left == &right)        
        return true;

    typename MapT::const_iterator left_  = left.begin();
    typename MapT::const_iterator right_ = right.begin();

    left_  = next_proton(left_,  left);
    right_ = next_proton(right_, right);

    while(left_ != left.end() && right_ != right.end())
    {
        if(!(left_->first == right_->first && left_->second == right_->second))
            return false;

        ++left_;
        ++right_;
        left_  = next_proton(left_,  left);
        right_ = next_proton(right_, right);
    }

    return left_ == left.end() && right_ == right.end();
}
Пример #7
0
    //! @internal
    template <class Archive, class MapT> inline
    void load( Archive & ar, MapT & map )
    {
      size_type size;
      ar( make_size_tag( size ) );

      map.clear();

      auto hint = map.begin();
      for( size_t i = 0; i < size; ++i )
      {
        typename MapT::key_type key;
        typename MapT::mapped_type value;

        ar( make_map_item(key, value) );
        hint = map.emplace_hint( hint, std::move( key ), std::move( value ) );
      }
    }
Пример #8
0
    //! @internal
    template <class Archive, class MapT> inline
    void load( Archive & ar, MapT & map )
    {
      size_type size;
      ar( make_size_tag( size ) );

      map.clear();

      auto hint = map.begin();
      for( size_t i = 0; i < size; ++i )
      {
        typename MapT::key_type key;
        typename MapT::mapped_type value;

        ar( make_map_item(key, value) );
        #ifdef CEREAL_OLDER_GCC
        hint = map.insert( hint, std::make_pair(std::move(key), std::move(value)) );
        #else // NOT CEREAL_OLDER_GCC
        hint = map.emplace_hint( hint, std::move( key ), std::move( value ) );
        #endif // NOT CEREAL_OLDER_GCC
      }
    }
Пример #9
0
std::vector<typename MapT::mapped_type> map_values(MapT const& m)
{
	return map_values<typename MapT::mapped_type>(m.begin(), m.end());
}
Пример #10
0
std::vector<typename MapT::key_type> map_key(MapT const& m)
{
	return map_key<typename MapT::key_type>(m.begin(), m.end());
}
Пример #11
0
int ProcessError(
    IdType error_type,
    IdType error_Id,
    IdType error_ref,
    IdType error_cond,
    NetVT* net_values_FF,
    NetVT* net_values_E,
    IdType &start_module_Id,
    ForestT* forest,
    int thread_num)
{
    int retval = 0;
    start_module_Id = NULL_Id;

    IdType sum_Id2 = NULL_Id;
    MapT* map2 = &net_values_FF[error_cond].root_Ids;
    for (ValueType i=0; i<1; i++)
    {
        MapTI it = map2->find( i==0? 0 : (1<<net_widths[error_ref]) -1);
        if (it != map2->end())
        {
            if (sum_Id2 == NULL_Id) sum_Id2 = it->second;
            else {
                IdType temp_Id = NULL_Id;
                forest->AddTree(thread_num, it->second, sum_Id2, temp_Id, 0);
            }
        }
    }
    if (sum_Id2 == NULL_Id) return retval;


    switch (error_type)
    {
        case 0: // Bus line struck
        {
            net_values_E[error_Id].root_Ids.clear();
            IdType sum_Id = NULL_Id;
            MapT* map = &net_values_FF[error_Id].root_Ids;
            for (MapTI it = map->begin(); it != map->end(); it++)
            {
                if (sum_Id == NULL_Id) sum_Id = it->second;
                else {
                    IdType sum_Id2 = NULL_Id;
                    forest->AddTree(thread_num, it->second, sum_Id, sum_Id2, 0);
                    sum_Id = sum_Id2;
                }
            }
            net_values_E[error_Id].root_Ids.insert(MapTP(error_ref, sum_Id));
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 1: // Bus order error
        {
            //IdType sum_Id = NULL_Id;
            MapT* map_ff = &net_values_FF[error_Id].root_Ids;
            MapT* map_e  = &net_values_E [error_Id].root_Ids;
            map_e->clear();
            for (MapTI it = map_ff->begin(); it != map_ff->end(); it++)
            {
                map_e->insert(MapTP(Reverse(it->first), it->second));
            }
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 2: // Bus source error
        {
            //IdType sum_Id = NULL_Id;
            MapT* map_ff = &net_values_FF[error_ref].root_Ids;
            MapT* map_e  = &net_values_E [error_Id].root_Ids;
            map_e->clear();
            for (MapTI it = map_ff->begin(); it != map_ff->end(); it++)
            {
                map_e->insert(MapTP(it->first, it->second));
            }
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 3: // Bus count error
        {
            //IdType sum_Id = NULL_Id;
            MapT* map_ff = &net_values_FF[error_Id].root_Ids;
            MapT* map_e  = &net_values_E [error_Id].root_Ids;
            map_e->clear();
            for (MapTI it_ff = map_ff->begin(); it_ff != map_ff->end(); it_ff++)
            {
                ValueType value = it_ff->first & ((1<<error_ref)-1);
                MapTI it = map_ff->find(value);
                if (it == map_ff->end())
                    map_e->insert(MapTP(value, it_ff->second));
                else {
                    IdType temp_Id = NULL_Id;
                    retval = forest->AddTree(thread_num, it_ff->second, it->second, temp_Id, 0);
                    it->second = temp_Id;
                }
            }
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 4: // conditional bus stuck line
        {
            net_values_E[error_Id].root_Ids.clear();
            IdType sum_Id = NULL_Id;
            MapT* map = &net_values_FF[error_Id].root_Ids;
            for (MapTI it = map->begin(); it != map->end(); it++)
            {   
                if (sum_Id == NULL_Id) sum_Id = it->second;
                else {
                    IdType sum_Id2 = NULL_Id;
                    forest->AddTree(thread_num, it->second, sum_Id, sum_Id2, 0); 
                    sum_Id = sum_Id2;
                }   
            }
            if (sum_Id == NULL_Id) break;

            IdType temp_Id = NULL_Id;
            forest->AndTree(thread_num, sum_Id, sum_Id2, temp_Id, 0);
            if (temp_Id != NULL_Id)
            {
                net_values_E[error_Id].root_Ids.insert(MapTP(error_ref,temp_Id));
            }
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 5: // conditional bus order error
        {
            MapT* map_ff = &net_values_FF[error_Id].root_Ids;
            MapT* map_e  = &net_values_E [error_Id].root_Ids;
            map_e->clear();
            for (MapTI it = map_ff->begin(); it != map_ff->end(); it++)
            {   
                IdType temp_Id = NULL_Id;
                forest->AndTree(thread_num, it->second, sum_Id2, temp_Id, 0);
                if (temp_Id == NULL_Id) continue;
                map_e->insert(MapTP(Reverse(it->first), temp_Id));
            }   
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case 6: // conditional bus source error
        {
            //IdType sum_Id = NULL_Id;
            MapT* map_ff = &net_values_FF[error_ref].root_Ids;
            MapT* map_e  = &net_values_E [error_Id].root_Ids;
            map_e->clear();
            for (MapTI it = map_ff->begin(); it != map_ff->end(); it++)
            {
                IdType temp_Id = NULL_Id;
                forest->AndTree(thread_num, it->second, sum_Id2, temp_Id, 0);
                if (temp_Id == NULL_Id) continue;  
                map_e->insert(MapTP(it->first, temp_Id));
            }
            start_module_Id = nets[error_Id]->to_module;
            break;
        }
        case NUM_NET_ERRORS + 0: // bypass module
        {
            ModuleT* module = modules[error_Id];
            MapT* map_input = &net_values_FF[module->input_Ids[error_ref]].root_Ids;
            MapT* map_output = &net_values_E[module->output_Ids[error_cond]].root_Ids;
            map_output->clear();
            
            for (MapTI it= map_input->begin(); it!= map_input->end(); it++)
            {
                map_output->insert(MapTP(it->first, it->second));
            }
            start_module_Id = nets[module->output_Ids[error_cond]]->to_module;
            break;
        }
        case NUM_NET_ERRORS + 1: // Add not to outputs
        {
            ModuleT* module = modules[error_Id];
            IdType net_Id = module->output_Ids[error_ref];
            MapT* map_ff = &net_values_FF[net_Id].root_Ids;
            MapT* map_e  = &net_values_E [net_Id].root_Ids;
            map_e->clear();
           
            for (MapTI it = map_ff->begin(); it != map_ff->end(); it++)
            {
                map_e->insert(MapTP(~(it->first), it->second));
            }
            start_module_Id = nets[net_Id]->to_module;
            break;
        }
        case NUM_NET_ERRORS + 2: // Module substituation
        {
            
            break;
        }
        default: break;
    }
    return retval;
}