About CAlt Map EMail jacking 75gmail com CAtl
About CAlt. Map 최흥배 E-Mail : jacking 75@gmail. com
생성자 CAtl. Map( UINT n. Bins = 17, float f. Optimal. Load = 0. 75 f, float f. Lo. Threshold = 0. 25 f, float f. Hi. Threshold = 2. 25 f, UINT n. Block. Size = 10 ) throw ( ); 파라메터 n. Bins 저장 되어 있는 요소로의 포인트를 가진 bin 수. f. Optimal. Load 최적의 읽기 비율 f. Lo. Threshold 읽기 비율의 최저한의 수 f. Hi. Threshold 읽기 비율의 최대한의 수 n. Block. Size 블록 크기
// Example program for CAtl. Map class // Confirm the number of elements in the map ATLASSERT(my. Sin. Table. Get. Count()==45); #include "stdafx. h" #include "atlcoll. h" #include "math. h" // Walk through all the elements in the map. // First, get start position. POSITION pos; int key; double value; pos = my. Sin. Table. Get. Start. Position(); int main(int argc, char* argv[]) { // Create a map which stores a double // value using an integer key CAtl. Map<int, double> my. Sin. Table; int i; // Initialize the Hash Table my. Sin. Table. Init. Hash. Table(257); // Add items to the map for (i=0; i<90; i++) my. Sin. Table[i]=sin(i); // Confirm the map is valid my. Sin. Table. Assert. Valid(); // Confirm the number of elements in the map ATLASSERT(my. Sin. Table. Get. Count()==90); // Remove elements with even key values for (i=0; i<90; i+=2) my. Sin. Table. Remove. Key(i); } // Now iterate the map, element by element while (pos != NULL) { key = my. Sin. Table. Get. Key. At(pos); value = my. Sin. Table. Get. Next. Value(pos); } return 0;
#include <iostream> #include <windows. h> #include <atlcoll. h> void main() { CAtl. Map< int, Game. Item > Atl. Map. Test; using namespace std; Game. Item t. Game. Item 1(1, 1000); Atl. Map. Test. Set. At( 1, t. Game. Item 1 ); // CAtl. Map에서 사용하는 경우 기본 생성자 이외의 생성자 를 // 정의하면 무조건 기본 생성자를 정의해야 CAtl. Map에서 // 사용할 수 있다. struct Game. Item { Game. Item() { } Game. Item t. Game. Item 2(2, 344); Atl. Map. Test. Set. At( 2, t. Game. Item 2 ); Game. Item( int Item. Cd, int Buy. Money ) { _Item. Cd = Item. Cd; _Buy. Money = Buy. Money; } }; int _Item. Cd; int _Buy. Money; Game. Item t. Game. Item 3(3, 2000); Atl. Map. Test. Set. At( 3, t. Game. Item 3 ); CAtl. Map< int, Game. Item >: : CPair* pair = NULL; POSITION pos = Atl. Map. Test. Get. Start. Position(); while (pos) { pair = Atl. Map. Test. Get. Next(pos); cout << "Key(" << pair->m_key << ") Value(" << pair>m_value. _Buy. Money << ")" << endl; } }
예) CAtl. Map< int, Game. Item > Atl. Map. Test; ……. . CAtl. Map< int, Game. Item >: : CPair* p. Find. Value = Atl. Map. Test. Lookup(2); // 값 변경도 가능 p. Find. Value->m_value. _Buy. Money = 400;
Set. Value. At 값 변경 원형 : void Set. Value. At( POSITION pos, VINARGTYPE value ); 파라메터 pos value CAtl. Map: : Get. Next. Assoc 또는 CAtl. Map: : Get. Start. Position 로의 이전 호출에서 반환된 위치. CAtl. Map 오브젝트에 추가하는 값. CAtl. Map 오브젝트 내의 지정한 위치에 저장되어 있는 값을 변경한다.
순회 예제 CAtl. Map< int, Game. Item > Atl. Map. Test; ……. CAtl. Map< int, Game. Item >: : CPair* pair = NULL; POSITION pos = Atl. Map. Test. Get. Start. Position(); while (pos) { pair = Atl. Map. Test. Get. Next(pos); cout << "Key(" << pair->m_key << ") Value(" << pair->m_value. _Buy. Money << ")" << endl; }
http: //msdn. microsoft. com/ja-jp/library/49 x 7 ef 2 y(VS. 80). aspx
- Slides: 28