Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ custom comparator for elements 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 :: 2114. Maximum Number of Words Found in Sentences leetcode solution in c++ 
Cpp :: check if key exists in map c++ 
Cpp :: struct and pointers (retun function) in c++ 
Cpp :: c++std vector three elemet c++ 
Cpp :: count a character in a string c++ 
Cpp :: should i learn c or c++ 
Cpp :: c++ get cursor position console 
Cpp :: bits/stdc++.h visual studio 
Cpp :: how to get mouse position on window sfm; 
Cpp :: is there an algorithm to create a truly random password 
Cpp :: C++ Third angle of a Triangle 
Cpp :: check file exist cpp 
Cpp :: c++ save typeid 
Cpp :: ue4 ftext to int 
Cpp :: cpp code for euclids GCD 
Cpp :: meter espacios en cadena c 
Cpp :: reverse an array using pointers in c++ 
Cpp :: ifstream relative file path 
Cpp :: size of 2d array in c++ 
Cpp :: how to access struct variables in c++ 
Cpp :: is C++ useful in 2021 
Cpp :: retu7rn this c++ 
Cpp :: iterate vector from end to begin 
Cpp :: format string cpp 
Cpp :: c++ check first character of string 
Cpp :: how to traverse a linked list in c++ 
Cpp :: how to run a msi file raspbrain 
Cpp :: max of two elements c++ 
Cpp :: scan line in c++ 
Cpp :: Heap pinter c++ 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =