/
IndexReference.cs
49 lines (40 loc) · 1.13 KB
/
IndexReference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CC_CEDICT.WindowsPhone
{
public class IndexReference : IComparable, IEquatable<IndexReference>
{
public string Key;
public int Index;
public int Relevance;
#region IComparable interface
int IComparable.CompareTo(object obj)
{
IndexReference other = (IndexReference)obj;
if (this.Relevance > other.Relevance)
return -1;
else if (this.Relevance == other.Relevance)
return this.Key.CompareTo(other.Key);
else
return 1;
}
#endregion
#region IEquatable interface
public bool Equals(IndexReference other)
{
return Index == other.Index;
}
public override bool Equals(object obj)
{
IndexReference other = (IndexReference)obj;
return other != null && Equals(other);
}
#endregion
public override int GetHashCode()
{
return Index.GetHashCode();
}
}
}