STL-- priority_queue overloaded

<Overloads in ascending order according to the size of the dis

1,

typedef struct Node     // queue should be to put the point id and distance, rather than one side 
{
     int id;    
     int DIS;    
    Node () {} 
    Node ( int   A, int B): id (A), DIS ( B)} {
     BOOL  operator <( const Node a &) const   // <overloading 
    {
         return a.dis < DIS; 
    } 
} ST; 
the priority_queue <ST> Q;

2,

typedef struct Node     // queue should be to put the point id and distance, rather than one side 
{
     int id;
     int DIS; 
    Node () {} 
    Node ( int   A, int B): id (A), DIS ( B) {} 
    Friend BOOL  operator <( const Node a &, const Node & B)   // <overloads 
    {
         return a.dis> b.dis; 
    } 
} ST; 
the priority_queue <ST> Q;

1,2 equivalent, ascending

 

========= ======== ======== ======= ====== ==== === == =

Even afraid to try anything they like it, after all, they even look down on themselves 

 

Guess you like

Origin www.cnblogs.com/asdfknjhu/p/12596117.html