전체 글328 CPP_1. AssortRock 9일차 오프라인 수업_220919 해시 테이블 Direct Addressing Table : 값을 인덱스로 사용하는 방식 ('A' = 65이므로 65번 인덱스로 'A'의 유무를 체크) 이 방식을 다른 말로 해시테이블이라고 한다. 해시테이블은 해시 함수가 있는데 문자를 넣어주면 고유의 식을 이용하여 결과물을 반환해준다. 해시테이블의 장점은 암호화를 할 수 있고 속도가 빠름 단점은 다른 값에 대해 동일한 해시값이 나올 수 있음 그럼 해시 충돌이 발생하고 그걸 연결 리스트로 주렁 주렁 연결함 이걸 해시 체이닝이라고 한다(면접 단골 질문) 연산자 오버로딩에 대하여 사용자정의 타입에 대해 덧셈 뺄셈을 하려면 인자를 빼서 걔네끼리 더해주고 빼주고 해야 함 클래스와 클래스 간의 연산을 하고 싶다면? Vector2 v3 = v1 + v2 반환값 ope.. 2022. 9. 20. 6-2-3. Critical Section 실습 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; CRITICAL_SECTION cs; int totalCount = 0; UINT threadProc(void* p) { totalCount++; int count = totalCount; static int value = 0; printf("%d번째 쓰레드 진입.. value = %d\n", count, value); EnterCriticalSection(&cs); for (int i = 0; i < 100; i++) value += 1; LeaveCriticalSection(&cs); printf("\t%d번째 쓰레드 종료.. .. 2022. 9. 20. 6-2-2. Event 실습 배운 이론을 실습하는 과정 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; int globalMemory = 0; HANDLE hEvent = INVALID_HANDLE_VALUE; UINT writeValueProc(void* p) { static int increase = 100; globalMemory += increase; SetEvent(hEvent); return 0; } UINT readValueProc(void* p) { //WaitForSingleObject(hEvent, INFINITE); printf("read value : %d\n", globalMemory.. 2022. 9. 20. 6-2-1. Semaphore 실습 배운 이론을 실습하는 과정 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; HANDLE hSemaphore = INVALID_HANDLE_VALUE; int totalCount = 0; UINT threadProc(void* p) { totalCount++; int count = totalCount; WaitForSingleObject(hSemaphore, INFINITE); printf("Start Routine %d!\n", count); Sleep(3000); printf("End Routine %d!\n", count); ReleaseSemaphore(hSemaphore,.. 2022. 9. 20. 이전 1 ··· 67 68 69 70 71 72 73 ··· 82 다음