IJV.h 606 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Templates:
  2. template <typename I,typename V>
  3. struct IJV
  4. {
  5. // Subscripts
  6. I i,j;
  7. // Value
  8. V v;
  9. IJV(int i, int j, double v)
  10. {
  11. this->i = i;
  12. this->j = j;
  13. this->v = v;
  14. }
  15. // Compare based on i then j
  16. bool operator<(const IJV & B) const
  17. {
  18. if(this->i < B.i)
  19. {
  20. return true;
  21. }else if(this->i > B.i)
  22. {
  23. return false;
  24. }else
  25. {
  26. if(this->j < B.j)
  27. {
  28. return true;
  29. }else if(this->j > B.j)
  30. {
  31. return false;
  32. }else
  33. {
  34. // i and j are equal
  35. return false;
  36. }
  37. }
  38. return false;
  39. }
  40. };