1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/profiler/csharp/Comparators.cs Sun Mar 30 07:00:22 2008 +0000
1.3 @@ -0,0 +1,85 @@
1.4 +using System;
1.5 +using System.Collections;
1.6 +using System.Text;
1.7 +using System.Windows.Forms;
1.8 +
1.9 +namespace profviewer
1.10 +{
1.11 + class LIStringComparator : IComparer
1.12 + {
1.13 + private int m_col;
1.14 +
1.15 + public LIStringComparator(int col)
1.16 + {
1.17 + m_col = col;
1.18 + }
1.19 +
1.20 + public int Compare(object x, object y)
1.21 + {
1.22 + ListViewItem a = (ListViewItem)x;
1.23 + ListViewItem b = (ListViewItem)y;
1.24 +
1.25 + return String.Compare(a.SubItems[m_col].Text, b.SubItems[m_col].Text);
1.26 + }
1.27 + }
1.28 +
1.29 + class LIIntComparator : IComparer
1.30 + {
1.31 + private int m_col;
1.32 +
1.33 + public LIIntComparator(int col)
1.34 + {
1.35 + m_col = col;
1.36 + }
1.37 +
1.38 + public int Compare(object x, object y)
1.39 + {
1.40 + ListViewItem a = (ListViewItem)x;
1.41 + ListViewItem b = (ListViewItem)y;
1.42 +
1.43 + int num1 = Int32.Parse(a.SubItems[m_col].Text);
1.44 + int num2 = Int32.Parse(b.SubItems[m_col].Text);
1.45 +
1.46 + if (num1 > num2)
1.47 + {
1.48 + return -1;
1.49 + }
1.50 + else if (num1 < num2)
1.51 + {
1.52 + return 1;
1.53 + }
1.54 +
1.55 + return 0;
1.56 + }
1.57 + }
1.58 +
1.59 + class LIDoubleComparator : IComparer
1.60 + {
1.61 + private int m_col;
1.62 +
1.63 + public LIDoubleComparator(int col)
1.64 + {
1.65 + m_col = col;
1.66 + }
1.67 +
1.68 + public int Compare(object x, object y)
1.69 + {
1.70 + ListViewItem a = (ListViewItem)x;
1.71 + ListViewItem b = (ListViewItem)y;
1.72 +
1.73 + double num1 = Double.Parse(a.SubItems[m_col].Text);
1.74 + double num2 = Double.Parse(b.SubItems[m_col].Text);
1.75 +
1.76 + if (num1 > num2)
1.77 + {
1.78 + return -1;
1.79 + }
1.80 + else if (num1 < num2)
1.81 + {
1.82 + return 1;
1.83 + }
1.84 +
1.85 + return 0;
1.86 + }
1.87 + }
1.88 +}