|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Collections; |
|
19 using System.Collections.Generic; |
|
20 |
|
21 namespace SymbianStructuresLib.CodeSegments.Internal |
|
22 { |
|
23 internal class CSDCompareByFileName : IComparer<CodeSegDefinition> |
|
24 { |
|
25 #region IComparer Members |
|
26 public int Compare( object aLeft, object aRight ) |
|
27 { |
|
28 CodeSegDefinition left = (CodeSegDefinition) aLeft; |
|
29 CodeSegDefinition right = (CodeSegDefinition) aRight; |
|
30 // |
|
31 return Compare( left, right ); |
|
32 } |
|
33 #endregion |
|
34 |
|
35 #region From IComparer<CodeSegDefinition> |
|
36 int IComparer<CodeSegDefinition>.Compare( CodeSegDefinition aLeft, CodeSegDefinition aRight ) |
|
37 { |
|
38 return string.Compare( aLeft.FileName, aRight.FileName, StringComparison.CurrentCultureIgnoreCase ); |
|
39 } |
|
40 #endregion |
|
41 } |
|
42 |
|
43 internal class CSDCompareByAddress : IComparer<CodeSegDefinition> |
|
44 { |
|
45 #region IComparer Members |
|
46 public int Compare( object aLeft, object aRight ) |
|
47 { |
|
48 CodeSegDefinition left = (CodeSegDefinition) aLeft; |
|
49 CodeSegDefinition right = (CodeSegDefinition) aRight; |
|
50 // |
|
51 return Compare( left, right ); |
|
52 } |
|
53 #endregion |
|
54 |
|
55 #region IComparer Members |
|
56 int IComparer<CodeSegDefinition>.Compare( CodeSegDefinition aLeft, CodeSegDefinition aRight ) |
|
57 { |
|
58 int ret = -1; |
|
59 if ( aLeft.Base == aRight.Base && aLeft.Limit == aRight.Limit ) |
|
60 { |
|
61 ret = 0; |
|
62 } |
|
63 else if ( aLeft.Limit == aRight.Base ) |
|
64 { |
|
65 System.Diagnostics.Debug.Assert( aLeft.Base < aRight.Base ); |
|
66 System.Diagnostics.Debug.Assert( aRight.Limit >= aLeft.Limit ); |
|
67 // |
|
68 ret = -1; |
|
69 } |
|
70 else if ( aLeft.Base == aRight.Limit ) |
|
71 { |
|
72 System.Diagnostics.Debug.Assert( aRight.Base < aLeft.Base ); |
|
73 System.Diagnostics.Debug.Assert( aLeft.Limit >= aRight.Limit ); |
|
74 // |
|
75 ret = 1; |
|
76 } |
|
77 else if ( aLeft.Base > aRight.Limit ) |
|
78 { |
|
79 System.Diagnostics.Debug.Assert( aLeft.Limit > aRight.Limit ); |
|
80 System.Diagnostics.Debug.Assert( aLeft.Limit > aRight.Base ); |
|
81 ret = 1; |
|
82 } |
|
83 else if ( aLeft.Limit < aRight.Base ) |
|
84 { |
|
85 System.Diagnostics.Debug.Assert( aLeft.Base < aRight.Limit ); |
|
86 System.Diagnostics.Debug.Assert( aRight.Limit > aLeft.Limit ); |
|
87 ret = -1; |
|
88 } |
|
89 // |
|
90 return ret; |
|
91 } |
|
92 #endregion |
|
93 } |
|
94 } |