|
1 /* |
|
2 * Copyright (c) 2004-2008 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 |
|
18 using System; |
|
19 using System.Collections.Generic; |
|
20 using System.Text; |
|
21 using CrashDebuggerLib.Structures.KernelObjects; |
|
22 |
|
23 namespace CrashDebuggerLib.Structures.Chunk |
|
24 { |
|
25 public class ChunkCollection : IEnumerable<DChunk> |
|
26 { |
|
27 #region Constructors |
|
28 public ChunkCollection() |
|
29 { |
|
30 } |
|
31 #endregion |
|
32 |
|
33 #region API |
|
34 public void Add( DChunk aChunk ) |
|
35 { |
|
36 iEntries.Add( aChunk ); |
|
37 } |
|
38 #endregion |
|
39 |
|
40 #region Properties |
|
41 public DChunk this[ int aIndex ] |
|
42 { |
|
43 get { return iEntries[ aIndex ]; } |
|
44 } |
|
45 |
|
46 public int Count |
|
47 { |
|
48 get { return iEntries.Count; } |
|
49 } |
|
50 #endregion |
|
51 |
|
52 #region Internal methods |
|
53 #endregion |
|
54 |
|
55 #region Internal constants |
|
56 #endregion |
|
57 |
|
58 #region From System.Object |
|
59 public override string ToString() |
|
60 { |
|
61 return base.ToString(); |
|
62 } |
|
63 #endregion |
|
64 |
|
65 #region From IEnumerable<Chunk> |
|
66 public IEnumerator<DChunk> GetEnumerator() |
|
67 { |
|
68 return new ChunkEnumerator( this ); |
|
69 } |
|
70 |
|
71 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
72 { |
|
73 return new ChunkEnumerator( this ); |
|
74 } |
|
75 #endregion |
|
76 |
|
77 #region Data members |
|
78 private List<DChunk> iEntries = new List<DChunk>(); |
|
79 #endregion |
|
80 } |
|
81 |
|
82 #region Internal enumerator |
|
83 internal class ChunkEnumerator : IEnumerator<DChunk> |
|
84 { |
|
85 #region Constructors |
|
86 public ChunkEnumerator( ChunkCollection aList ) |
|
87 { |
|
88 iList = aList; |
|
89 } |
|
90 #endregion |
|
91 |
|
92 #region IEnumerator Members |
|
93 public void Reset() |
|
94 { |
|
95 iCurrentIndex = -1; |
|
96 } |
|
97 |
|
98 public object Current |
|
99 { |
|
100 get |
|
101 { |
|
102 return iList[ iCurrentIndex ]; |
|
103 } |
|
104 } |
|
105 |
|
106 public bool MoveNext() |
|
107 { |
|
108 return ( ++iCurrentIndex < iList.Count ); |
|
109 } |
|
110 #endregion |
|
111 |
|
112 #region From IEnumerator<Chunk> |
|
113 DChunk IEnumerator<DChunk>.Current |
|
114 { |
|
115 get { return iList[ iCurrentIndex ]; } |
|
116 } |
|
117 #endregion |
|
118 |
|
119 #region From IDisposable |
|
120 public void Dispose() |
|
121 { |
|
122 } |
|
123 #endregion |
|
124 |
|
125 #region Data members |
|
126 private readonly ChunkCollection iList; |
|
127 private int iCurrentIndex = -1; |
|
128 #endregion |
|
129 } |
|
130 #endregion |
|
131 } |