|
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 "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-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.Text; |
|
19 using System.IO; |
|
20 using System.Collections.Generic; |
|
21 using CrashItemLib.Crash; |
|
22 using CrashItemLib.Crash.Base; |
|
23 using CrashItemLib.Crash.Registers; |
|
24 using CrashItemLib.Crash.Container; |
|
25 using SymbianStructuresLib.Uids; |
|
26 |
|
27 namespace CrashItemLib.Crash.Base |
|
28 { |
|
29 public class CIElementList<T> : CIElementDictionary<T>, IEnumerable<T> where T : CIElement |
|
30 { |
|
31 #region Constructors |
|
32 public CIElementList( CIContainer aContainer ) |
|
33 : base( aContainer ) |
|
34 { |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public void Sort( Comparison<T> aComparisonFunction ) |
|
40 { |
|
41 iList.Sort( aComparisonFunction ); |
|
42 } |
|
43 |
|
44 public override void Clear() |
|
45 { |
|
46 base.Clear(); |
|
47 iList.Clear(); |
|
48 } |
|
49 |
|
50 /// <summary> |
|
51 /// Add the specified element to this list |
|
52 /// </summary> |
|
53 /// <param name="aEntry"></param> |
|
54 /// <returns>true if the item was added to the list, false if the item was not added (for example, it already exists)</returns> |
|
55 public override bool Add( T aEntry ) |
|
56 { |
|
57 bool added = base.Add( aEntry ); |
|
58 if ( added ) |
|
59 { |
|
60 iList.Add( aEntry ); |
|
61 } |
|
62 return added; |
|
63 } |
|
64 |
|
65 public override void Remove( T aEntry ) |
|
66 { |
|
67 base.Remove( aEntry ); |
|
68 iList.Remove( aEntry ); |
|
69 } |
|
70 |
|
71 public void RemoveAt( int aIndex ) |
|
72 { |
|
73 iList.RemoveAt( aIndex ); |
|
74 } |
|
75 |
|
76 public virtual T[] ToArray() |
|
77 { |
|
78 return iList.ToArray(); |
|
79 } |
|
80 #endregion |
|
81 |
|
82 #region Properties |
|
83 public new T this[ int aIndex ] |
|
84 { |
|
85 get { return iList[ aIndex ]; } |
|
86 } |
|
87 #endregion |
|
88 |
|
89 #region Internal methods |
|
90 #endregion |
|
91 |
|
92 #region From IEnumerable<T> |
|
93 public new IEnumerator<T> GetEnumerator() |
|
94 { |
|
95 foreach ( T element in iList ) |
|
96 { |
|
97 yield return element; |
|
98 } |
|
99 } |
|
100 |
|
101 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
102 { |
|
103 foreach ( T element in iList ) |
|
104 { |
|
105 yield return element; |
|
106 } |
|
107 } |
|
108 #endregion |
|
109 |
|
110 #region From System.Object |
|
111 public override string ToString() |
|
112 { |
|
113 StringBuilder ret = new StringBuilder(); |
|
114 ret.AppendFormat( "[{0}] {1} item{2}", typeof( T ).Name, iList.Count, iList.Count == 0 || iList.Count > 1 ? "s" : string.Empty ); |
|
115 return ret.ToString(); |
|
116 } |
|
117 #endregion |
|
118 |
|
119 #region Data members |
|
120 private List<T> iList = new List<T>(); |
|
121 #endregion |
|
122 } |
|
123 } |