00001 // XYVector.cpp: implementation of the CXYVector class. 00002 // 00004 00005 #include "XYVector.h" 00006 00008 // Construction/Destruction 00010 00011 CXYVector::CXYVector() 00012 { 00013 00014 } 00015 00016 CXYVector::~CXYVector() 00017 { 00018 for(int i = 0; i < m_vpXYVector.size(); i++) 00019 { 00020 delete m_vpXYVector[i]; 00021 } 00022 } 00023 00024 void CXYVector::SetXYPair(int n, double x, double y) 00025 { 00026 if(n > m_vpXYVector.size()) 00027 { 00028 return; 00029 } 00030 00031 m_vpXYVector[n]->SetX(x); 00032 m_vpXYVector[n]->SetY(y); 00033 } 00034 00035 void CXYVector::AddXYPoint(double x, double y) 00036 { 00037 m_vpXYVector.push_back(new CXYPoint(x,y)); 00038 } 00039 00040 void CXYVector::SortOnX() 00041 { 00042 // use STL sort with the correct comparator 00043 CXYPoint::CXComparator xcomp; 00044 std::sort(m_vpXYVector.begin(),m_vpXYVector.end(),xcomp); 00045 } 00046 00047 void CXYVector::SortOnY() 00048 { 00049 // use STL sort with the correct comparator 00050 CXYPoint::CYComparator ycomp; 00051 std::sort(m_vpXYVector.begin(),m_vpXYVector.end(),ycomp); 00052 }