#ifndef KNN_HEADER_H
#define KNN_HEADER_H


using namespace std;  
typedef struct tagRoadKey 
{int x;
int y;
bool operator <(const tagRoadKey& other) const
{
	if (x < other.x)        //类型按升序排序
	{
		return true;
	}
	else if (x == other.x)  //如果类型相同，按比例尺升序排序
	{
		if (y < other.y)        //类型按升序排序
	    {
		    return true;
	    }
		else
		{
			return false;
		}
	}

	return false;
}
}Point;

typedef Point tLabel;  
typedef double tData;  
typedef pair<int,double>  PAIR;  

  
const int colLen = 3;  
const int rowLen = 13000; 
extern ifstream fin;  
extern ofstream fout;    

class KNN  
{  
private:  
        tData dataSet[rowLen][colLen];  
        tLabel labels[rowLen];  
        tData testData[colLen];  
        int k;  
        map<int,double> map_index_dis;  
        map<tLabel,int> map_label_freq;  
        double get_distance(tData *d1,tData *d2);  
public:  
  
        KNN(int magic_x, int magic_y, int magic_z);  
  
        void get_all_distance();  
          
        tLabel get_max_freq_label();  
  
        struct CmpByValue  
        {  
            bool operator() (const PAIR& lhs,const PAIR& rhs)  
            {  
                return lhs.second < rhs.second;  
            }  
        };  
          
};  

  
#endif