Query regarding stl functions

what all stl functions should i always keep in my mind and also tell the difference between find and search stl fuctions.

@Parmeet-Kalsi-1631789033630118 map set list deque sort heaps stack queue and all …
and about find and search read about them from gfg to have better understanding
in short-
find-
Finds the element in the given range of numbers. Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
search-
std::search is defined in the header file and used to find out the presence of a subsequence satisfying a condition (equality if no such predicate is defined) with respect to another sequence.

  • It searches the sequence [first1, last1) for the first occurrence of the subsequence defined by [first2, last2), and returns an iterator to its first element of the occurrence, or last1 if no occurrences are found.
  • It compares the elements in both ranges sequentially using operator== (version 1) or based on any given predicate (version 2). A subsequence of [first1, last1) is considered a match only when this is true for all the elements of [first2, last2). Finally, std::search returns the first of such occurrences.
    dont forget to hit like and mark resolved if cleared :smiley:

if we are having an array or vector of objects of a particular class and we want to find a particular object from the array or vector , then does the find function by default compares all the data members of the object we are looking for to the data members of the objects of the array or vector or we have to define our own comparator as c++ stl can’t compare two objects .

@Parmeet-Kalsi-1631789033630118 i think it returns the first one it encountered as it starts from begin

I M asking how the comparison will occur by default find function between two objects whether all the data members will be compared or something else or we have to define comparator class each time

@Parmeet-Kalsi-1631789033630118 i dont understand what you are trying to say give an example

let us assume i had created an
vector of book objects ( which contains the name of book and its price as data members)
let us vector contain-
c++,100;
java,115;
pyrhon,130;

now i want to search an object
java,115;
in the vector , so for that will we use either find function or search function?(1st question)

(2nd question) using find/search will it compare all the data members of the object we need to search to the
data members of the objects in array or something else or do we need need to create our own comparator class each time as in c++
(3rd question) is it true that we can’t compare two objects without a comparator class

@Parmeet-Kalsi-1631789033630118 (1)find function will do the work and (2)you have to make the comparator on which basis it need to compare (3) yes you cant compare them directly in c++ ( but i think its possible in java)

Thanks buddy i got it now
Just tell me one more thing do classes and objects also play the role of what structures do in c language.
And
Is it necessary to know how a function is written in c++ stl as in programming we just use stl.

Thanks buddy i got it now
Just tell me one more thing do classes and objects also play the role of what structures do in c language.
And
Is it necessary to know how a function is written in c++ stl as in programming we just use stl.

@Parmeet-Kalsi-1631789033630118 classes and objects do the same thing you can use structures too in c++. but in struct you cant define function inside .
no its not necessary in depth just know the complexities and arguments it can take and what it do.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.