2009-08-20 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System / System.Collections.Specialized / StringCollection.cs
1 //
2 // StringCollection.cs
3 //
4 // Authors:
5 //      John Barnette (jbarn@httcb.net)
6 //      Sean MacIsaac (macisaac@ximian.com)
7 //      Ben Maurer (bmaurer@users.sourceforge.net)
8 //
9 // (C) 2003 Ben Maurer
10 // Copyright (C) 2001 John Barnette
11 // (C) Ximian, Inc.  http://www.ximian.com
12
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34
35 namespace System.Collections.Specialized {
36         
37         [Serializable]
38         public class StringCollection : IList {
39                 ArrayList data = new ArrayList ();
40         
41                 public string this [int index] {
42                         get { return (string)data [index]; }
43                         set { data [index] = value;     }
44                 }
45                 
46                 public int Count {
47                         get { return data.Count; }
48                 }
49
50                 bool IList.IsReadOnly {
51                         get { return false; }
52                 }
53                 
54                 bool IList.IsFixedSize {
55                         get { return false; }
56                 }
57                 
58                 
59                 public int Add (string value) {
60                         return data.Add (value);
61                 }
62                 
63                 public void AddRange (string [] value) {
64                         if (value == null)
65                                 throw new ArgumentNullException ("value");
66
67                         data.AddRange (value);
68                 }
69                 
70                 public void Clear () {
71                         data.Clear ();
72                 }
73                 
74                 public bool Contains (string value) {
75                         return data.Contains (value);
76                 }
77                 
78                 public void CopyTo (string [] array, int index) {
79                         data.CopyTo (array, index);
80                 }
81                 
82                 public StringEnumerator GetEnumerator () {
83                         return new StringEnumerator (this);
84                 }
85                 
86                 public int IndexOf (string value) {
87                         return data.IndexOf (value);
88                 }
89                 
90                 public void Insert(int index, string value) {
91                         data.Insert (index, value);
92                 }
93                 
94                 public bool IsReadOnly {
95                         get { return false; }
96                 }
97                 
98                 public bool IsSynchronized {
99                         get { return false; }
100                 }
101                 
102                 public void Remove (string value) {
103                         data.Remove (value);
104                 }
105                 
106                 public void RemoveAt (int index) {
107                         data.RemoveAt (index);
108                 }
109                 
110                 public object SyncRoot {
111                         get { return this; }
112                 }
113                 
114                 object IList.this [int index] {
115                         get { return this [index]; }
116                         set { this [index] = (string)value; }
117                 }
118                 
119                 int IList.Add (object value) {
120                         return Add ((string)value);
121                 }
122                 
123                 bool IList.Contains (object value) {
124                         return Contains ((string) value);
125                 }
126
127                 int IList.IndexOf (object value) {
128                         return IndexOf ((string)value);
129                 }
130                 
131                 void IList.Insert (int index, object value) {
132                         Insert (index, (string)value);
133                 }
134                 
135                 void IList.Remove (object value) {
136                         Remove ((string)value);
137                 }
138                 
139                 void ICollection.CopyTo (Array array, int index) {
140                         data.CopyTo (array, index);
141                 }
142                 
143                 IEnumerator IEnumerable.GetEnumerator () {
144                         return data.GetEnumerator ();
145                 }
146         }
147 }