2 // System.CodeDOM CodeStatementCollection Class implementation
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) 2001 Ximian, Inc.
10 namespace Mono
.MonoBASIC
{
12 using System
.Collections
;
15 public class StatementCollection
: IList
, ICollection
, IEnumerable
{
22 public StatementCollection ()
24 statements
= new ArrayList ();
32 return statements
.Count
;
39 public void Add (Statement
value)
41 statements
.Add (value);
44 public void AddRange (Statement
[] values
)
46 foreach (Statement ca
in values
)
56 private class Enumerator
: IEnumerator
{
57 private StatementCollection collection
;
58 private int currentIndex
= -1;
60 internal Enumerator (StatementCollection collection
)
62 this.collection
= collection
;
65 public object Current
{
67 if (currentIndex
== collection
.Count
)
68 throw new InvalidOperationException ();
69 return collection
[currentIndex
];
73 public bool MoveNext ()
75 if (currentIndex
> collection
.Count
)
76 throw new InvalidOperationException ();
77 return ++currentIndex
< collection
.Count
;
86 public IEnumerator
GetEnumerator ()
88 return new StatementCollection
.Enumerator (this);
92 // IList method implementations
94 public int Add (object value)
96 return statements
.Add (value);
99 public bool Contains (Object
value)
101 return statements
.Contains (value);
104 public int IndexOf (Object
value)
106 return statements
.IndexOf (value);
109 public void Insert (int index
, Object
value)
111 statements
[index
] = value;
114 public object this[int index
] {
116 return statements
[index
];
120 statements
[index
] = value;
124 public void Remove (object value)
126 statements
.Remove (value);
129 public void RemoveAt (int index
)
131 statements
.RemoveAt (index
);
135 // ICollection method implementations
137 public void CopyTo (Array array
, int index
)
139 statements
.CopyTo (array
, index
);
142 public object SyncRoot
{
144 return statements
.SyncRoot
;
148 public bool IsReadOnly
{
154 public bool IsSynchronized
{
156 return statements
.IsSynchronized
;
160 public bool IsFixedSize
{