L
Lieven
I want to make a quicksort algorithm that can take both a vector and a list.
This is the code I've got. But I also want to give an argument that will be
used for comparing the elements. I am used to programming in Lisp/Scheme,
where I would just pass a lambda. Is a function object something like that
in C++? And in that case, how would I pass the function/operator < (lesser
then).
//quicksort
template<typename BidirectionalIterator>
void quicksort(BidirectionalIterator& begin, BidirectionalIterator& end){
....
}
//partition function
template<typename BidirectionalIterator>
BidirectionalIterator partition(BidirectionalIterator& begin,
BidirectionalIterator& end){
....
}
This is the code I've got. But I also want to give an argument that will be
used for comparing the elements. I am used to programming in Lisp/Scheme,
where I would just pass a lambda. Is a function object something like that
in C++? And in that case, how would I pass the function/operator < (lesser
then).
//quicksort
template<typename BidirectionalIterator>
void quicksort(BidirectionalIterator& begin, BidirectionalIterator& end){
....
}
//partition function
template<typename BidirectionalIterator>
BidirectionalIterator partition(BidirectionalIterator& begin,
BidirectionalIterator& end){
....
}