CMAP 정렬관련 정리

1. HASH 를 정렬하는 방법

hash를 상용하더라도 순서는 정리 할 수 없는 듯 하다.

template <class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
CMap <KEY, ARG_KEY, VALUE, ARG_VALUE>:: CAssoc*
CMap <KEY, ARG_KEY, VALUE, ARG_VALUE>:: GetAssocAt (ARG_KEY key, UINT& nHash) const
//find association (or return NULL)
{
    nHash = HashKey <ARG_KEY> (key) % m_nHashTableSize;
    if (m_pHashTable == NULL)
        return NULL;
    //see if it exists
    CAssoc* pAssoc;
    for (pAssoc = m_pHashTable [nHash]; pAssoc! = NULL; pAssoc = pAssoc-> pNext)
    {
        if (CompareElements (&pAssoc->key, &key))
            return pAssoc;
    }
    return NULL;
}

2. Struct 를 만들어서 Pair Insert

Pair를 사용하는 별도의 map Class를 구현해야 함.

typedef struct tagPARAM { DWORD dwId;//Unique value DWORD dwVal; } TEMP_PARAM;

//임으로 Struc를 구성하고 Pair

typedef struct tagPARAM
{
    //... What that the data
} TEMP_PARAM;
typedef std:: map <DWORD, TEMP_PARAM> TEMP_MAP;
typedef std:: map <DWORD, TEMP_PARAM>:: iterator TEMP_MAP_ITER;
typedef std:: pair <DWORD, TEMP_PARAM> TEMP_MAP_PAIR;
//to work with this all approximately here so Further:
//to Fill. Thus the element takes at once a place according to the sorted order on dwID
TEMP_MAP map;
TEMP_PARAM param;
DWORD dwID;
map.insert (TEMP_MAP_PAIR (dwID, param));
//Search
TEMP_MAP_ITER it;
DWORD dwRequestID;
it = map.find (dwRequestID);//In the given iterator it-> second structure TEMP_PARAM

“CMAP 정렬관련 정리”의 13개의 댓글

  1. Do you have a spam problem on this website; I also am a blogger,
    and I was curious about your situation; many of us have developed some nice practices and we are looking to exchange techniques with others, please shoot me an e-mail if interested.

  2. Howdy! This is my first visit to your blog!
    We are a team of volunteers and starting a new project in a community in the same
    niche. Your blog provided us useful information to work on. You have
    done a outstanding job!

  3. I just want to say I am just very new to weblog and seriously savored your web page. Almost certainly I’m planning to bookmark your website . You actually come with outstanding well written articles. Kudos for sharing with us your blog site.

  4. Hey are using WordPress for your site platform? I’m new
    to the blog world but I’m trying to get started and
    set up my own. Do you need any html coding expertise to
    make your own blog? Any help would be greatly appreciated!

  5. Having read this I thought it was really enlightening.
    I appreciate you spending some time and effort
    to put this short article together. I once again find myself personally spending
    way too much time both reading and posting comments.
    But so what, it was still worth it!

댓글 남기기