G.I.S Developer, 개발자 김형준(Dip2K)  
Front Page
Notice | Keyword | Tag | E-Mail | Guestbook | Admin | Write Article   
 
2007/11/09 13:06 2007/11/09 13:06
STL map의 비교함수자 제공하는 코드

필요할때마다 잊는지라, 이곳에 메모해 봅니다.. ^^

#include <map>

using namespace std;

class Standard {
private:
	int a;
public:
	Standard(int a) {
		this->a = a;
	}

	int Get() {
		return a;
	}
};

class Value {
public:
	Standard *pStandard;
	Value(Standard *pStandard) {
		this->pStandard = pStandard;
	}
};

class CustomCompare {
public:
	bool operator()(Standard* s1, Standard* s2) const {
		return s1->Get() == s2->Get();
	}
};

int main(int argc, _TCHAR* argv[])
{
	map<Standard*, Value*, CustomCompare> container;

	Standard *pStand1 = new Standard(10);
	Value *pValue1 = new Value(pStand1);
	
	Standard *pStand2 = new Standard(20);
	Value *pValue2 = new Value(pStand2);

	container[pStand1] = pValue1;
	container[pStand2] = pValue2;

	Standard *pStand3 = new Standard(20);

	printf("%d\n", container[pStand3]->pStandard->Get());

	delete pStand3;
	delete pStand1;
	delete pStand2;
	delete pValue1;
	delete pValue2;

	return 0;
}
Track this back : http://www.gisdeveloper.co.kr/trackback/336

[로그인][오픈아이디란?]
name    password    homepage
 hidden
BLOG main image
 Notice
듀라맵(DuraMap) 라이센스 정책
듀라맵 소개 및 다운로드
OpenGL Tutorials
운영자(Dip2K)에 대해
 Category
전체 (401)
GIS 개발 (86)
프로그래밍 (188)
스치는 생각들 (117)
번역 또는 집필 (3)
 TAGS
GIS OpenGL Xr Shader Algorithm Map Engine WPF ArcObjects ArcGIS C++
 Calendar
«   2010/09   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
 Recent Entries
[ActionScript] Event 클...
[안드로이드] SD 카드에...
[안드로이드] 사용자 정의...
[안드로이드] 타이머 기능
[Java] @Override 어노테...
 Recent Comments
네, 일단 shp로 익스포팅...
김형준 - 09/01
혹시 변환된 좌표는 텍스...
박광호 - 09/01
아이폰4G가 현존하는 스마...
김형준(Dip2K) - 08/26
아이폰3Gs 는 320x480이고...
http://iyeti.kr/ - 08/26
안타깝지만... 이 프로그...
김형준 - 08/24
좋은자료 감사합니다....
박찬원 - 08/24
댓글, 감사합니다!
김형준(Dip2K) - 08/20
많은 도움이 됐습니다.
나쁜남자 - 08/20
저는 다음에 대한 요청 ur...
김형준 - 08/20
웹 트래픽을 추적하는 방...
강부자아들 - 08/20
 Archive
2010/09
2010/08
2010/07
2010/06
2010/05
2010/04
2010/03
2010/02
2010/01
2009/12
2009/11
2009/10
 Link Site
Adobe Flex 3 Help
Cartograph 2.0
GIS 위키디피아
GIS 프로그래밍 연구소
MapTools.org
OGC
OGRE3D
OSGeo 한국 지부
Wikipedia
국가수자원관리 정보시스템
국립지리원
국토연구원
국토해양부
네이버 과학
대한측량협회
류광님의 블로그
이민파님의 공간분석과 리...
 Visitor Statistics
Total : 678647
Today : 59
Yesterday : 403
태터툴즈 배너
rss