아이템
class SubtitleItem { public: enum SUBTITLE_DIRECTION { LEFT, RIGHT }; float time; SUBTITLE_DIRECTION direction; ofImage* image; static bool comp(const SubtitleItem *t1, const SubtitleItem *t2) { // 중요! return (t1->time < t2->time); } };
활용
cout << "SORT TEST" << endl; cout << "=========== before =========" << endl; for (int i = 0; i < collection.size(); i++) { cout << collection[i]->time << endl; } //sort sort(collection.begin(), collection.end(), SubtitleItem::comp); cout << "============ after =========" << endl; for (int i = 0; i < collection.size(); i++) { cout << collection[i]->time << endl; }
결과
'C++(일반)' 카테고리의 다른 글
sort 사용하기 (0) | 2016.08.19 |
---|---|
Cmd 명령으로 프로그램 실행 하기 (0) | 2016.08.10 |
_memcpy(...) with start Index. (0) | 2016.03.27 |
char 와 unsigned char (0) | 2016.03.27 |
c++ memorystream (0) | 2016.03.25 |
istream(ofstream) 사용시 주의점 ios::binary (0) | 2016.03.25 |