Coding Test

compare struct와 function 차이

Deviloper😈 2022. 9. 29. 14:47
// pq에 올림차순으로 넣고 싶을 때
struct cmp {
	bool operator() (Line a, Line b) {
		return a.e > b.e;
	}
};

priority_queue <Line, vector<Line>, cmp> pq;


// 벡터를 올림차순으로 sort하고 싶을 때
bool compare(Line a, Line b) {
	return a.s < b.s;
}

sort(monster.begin(), monster.end(), compare);

priority queue 에 들어갈 cmp bool struct