Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ custom compare in set

struct compare {
    bool operator() (const int& x, const int& y) const {
        return x<y; // if x<y then x will come before y. Change this condition as per requirement
    }
};
int main()
{
  set<int,compare> s; //use the comparator like this
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to take user input in a client server program in c++ 
Cpp :: map key exists c++ 
Cpp :: cpp speed cin cout 
Cpp :: check compiler version c++ 
Cpp :: print to console c++ 
Cpp :: how to append one vector to another c++ 
Cpp :: double max value c++ 
Cpp :: error: ‘memset’ was not declared in this scope in cpp 
Cpp :: find max value in image c++ 
Cpp :: commets in codeblocks 
Cpp :: what are specialized classes c++ 
Cpp :: resizing dynamic array c++ 
Cpp :: vs code text in line 
Cpp :: non stoichiometric nacl is yellow 
Cpp :: How to block window resize sfml c++ 
Cpp :: what is syntex for inheritence in c++ 
Cpp :: fibonacci in c++ 
Cpp :: priority queue c++ time complexity 
Cpp :: std cout c++ 
Cpp :: default rule of five c++ 
Cpp :: cpp float to int 
Cpp :: c++ check if string contains non alphanumeric 
Cpp :: c++ show current time 
Cpp :: heap buffer overflow c++ 
Cpp :: how to run a c++ program in the background 
Cpp :: read file into vector 
Cpp :: queue in c++ 
Cpp :: c++ case 
Cpp :: change to lowercase character c++ 
Cpp :: insert vector to end of vector c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =