comparator

MIPS Register comparator

Given two input registers in MIPS: $t0, $t1 How would you figure out which one is bigger without using branches? ...

Comparator for Generic Interface Without Warnings

Given: public interface PrimaryKey<Key extends Comparable> { Key getKey(); } and public class PrimaryKeyComparator implements Comparator<PrimaryKey> { public int compare(PrimaryKey first, PrimaryKey second) { return first.getKey().compareTo(second.getKey()); } } This combination works, but gives warnings about r...

Using comparator for STL set

Check the following code: string toLowerCase(const string& str) { string res(str); int i; for (i = 0; i < (int) res.size(); i++) res[i] = (char) tolower(res[i]); return res; } class LeagueComparator { public: bool operator()(const string& s1, const string& s2) { return toLowerCase(s1) < toLower...