예제 #1
0
파일: lists.hpp 프로젝트: r-lyeh/eve
            void go( bool construct )
            {
                typedef std::pair<std::string,int> key_t;
                typedef std::map<key_t, int> map_t;

                static map_t map;
                key_t id = key_t( file, line );
                map_t::iterator it = map.find( id );

                if( construct )
                {
                    compiled = ( it != map.end() );
                    if( !compiled )
                    {
                        static int list = 0;
                        list++;
                        map.insert( std::pair<key_t,int>( id, list) );
                        glNewList( list, GL_COMPILE );
                    }
                }
                else
                {
                    int list = it->second;
                    if( !compiled )
                    {
                        glEndList();
                        //std::cout << "compiled list #" << list << std::endl;
                    }
                    //std::cout << "calling list #" << list << std::endl;
                    glCallList( list );
                }
            }
예제 #2
0
 template <typename... IndexType> void insert(IndexType const&... ind) {
  map_index_n.insert({{ind...}, size()});
  // reorder the indices which are always given in the order of the indices tuple
  map_t m;
  int i = 0;
  for (auto const& p : map_index_n) m.insert({p.first, i++});
  std::swap(m, map_index_n);
 }
예제 #3
0
파일: module.cpp 프로젝트: doniexun/ldc
static void check_and_add_output_file(Module* NewMod, const std::string& str)
{
    typedef std::map<std::string, Module*> map_t;
    static map_t files;

    map_t::iterator i = files.find(str);
    if (i != files.end()) {
        Module* ThisMod = i->second;
        error(Loc(), "Output file '%s' for module '%s' collides with previous module '%s'. See the -oq option",
            str.c_str(), NewMod->toPrettyChars(), ThisMod->toPrettyChars());
        fatal();
    }
    files.insert(std::make_pair(str, NewMod));
}
예제 #4
0
        //Returns a reference to the resource associated with the file name 'key' if it exists in memory.
        //Otherwise it loads the texture into memory, and returns a reference to the the resource.
        T &Load(key_type const &key) noexcept(false)
        {
            map_i i = m_map.find(key);
            if(i != m_map.end())
            {
                return *i->second.get(); //return resource if exists
            }

            //else, load resource
            ptr_t p {onLoadResource(key)};
            if(p.get() == NULL)
            {
                throw Exception(std::string("Error loading Image at ") + key);
            }

            m_map.insert(std::make_pair(key, std::move(p)));
            return *m_map[key].get();
        }
예제 #5
0
 std::pair< map_t::iterator, bool > insert( const rule_type type )
 {
    return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) );
 }