
Untitled
By: a guest on
May 24th, 2012 | syntax:
None | size: 0.63 KB | hits: 14 | expires: Never
#include <algorithm>
#include <list>
#include <iostream>
using namespace std;
struct comparer {
int this_node;
comparer(int node) : this_node(node) {} // wtf? är det här ok?
bool operator()(int a, int b) {
return (a+this_node > b);//(d(this_node,a) < d(this_node,b));
}
};
int main()
{
int foo[] = {55, 22, 33, 11, -11, -33};
list<int> mylist (foo, foo+sizeof(foo)/sizeof(int));
mylist.sort(comparer(32));
for (list<int>::iterator it=mylist.begin(); it!=mylist.end(); ++it)
cout << " " << *it;
cout << endl;
}