날자별

2021 1월
 123
45678910
11121314151617
18192021222324
25262728293031

Sort Time

Algorithm

Average Time

Worst Time

Space

Bubble sort

n^2

vector의 sturct의 한 항목으로 Sort 하고자 할때

[cpp] typedef struct { int nNumber; int nTimeSeconds; int nConnections; } STasks;[/cpp]

[cpp] struct STaskSortAscending { bool operator() ( STasks& r_pElemStart, STasks& r_pElemEnd ) { return r_pElemStart.nNumber < r_pElemEnd.nNumber; } };[/cpp] [cpp] struct STaskSortDescending { bool operator() ( STasks& r_pElemStart, STasks& r_pElemEnd ) { return r_pElemStart.nNumber < r_pElemEnd.nNumber; } };[/cpp] [cpp]std::sort( m_vecTasks.begin(), m_vecTasks.end(), STaskSortAscending() );[/cpp] [...]