3 public struct KeyValuePair
<X
,Y
>
5 public KeyValuePair (X x
, Y y
)
9 public interface IComparer
<T
>
14 public class KeyValuePairComparer
<K
,V
> : IComparer
<KeyValuePair
<K
,V
>>
16 public int Compare (KeyValuePair
<K
,V
> a
)
22 public class TreeBag
<T
>
24 IComparer
<T
> comparer
;
26 public TreeBag (IComparer
<T
> comparer
)
28 this.comparer
= comparer
;
31 public int Find (ref T item
)
33 return comparer
.Compare (item
);
39 public static void Test ()
41 KeyValuePair
<int,int> pair
= new KeyValuePair
<int,int> (3, 89);
42 KeyValuePairComparer
<int,int> comparer
= new KeyValuePairComparer
<int,int> ();
43 TreeBag
<KeyValuePair
<int,int>> bag
= new TreeBag
<KeyValuePair
<int,int>> (comparer
);
51 public class KeyValuePair
<X
,Y
>
53 public KeyValuePair (X x
, Y y
)
57 public interface IComparer
<T
>
62 public class KeyValuePairComparer
<K
,V
> : IComparer
<KeyValuePair
<K
,V
>>
64 public int Compare (KeyValuePair
<K
,V
> a
)
70 public class TreeBag
<T
>
72 IComparer
<T
> comparer
;
74 public TreeBag (IComparer
<T
> comparer
)
76 this.comparer
= comparer
;
79 public int Find (ref T item
)
81 return comparer
.Compare (item
);
87 public static void Test ()
89 KeyValuePair
<int,int> pair
= new KeyValuePair
<int,int> (3, 89);
90 KeyValuePairComparer
<int,int> comparer
= new KeyValuePairComparer
<int,int> ();
91 TreeBag
<KeyValuePair
<int,int>> bag
= new TreeBag
<KeyValuePair
<int,int>> (comparer
);