New test.
[mono.git] / mcs / class / corlib / System.Collections / Stack.cs
index 9bc997e51adbd78cd903b69603b45ce16019a9a6..f4500a0c7d85aef03835656830829531a17fcfe1 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Runtime.InteropServices;
+
 namespace System.Collections {
+
+#if NET_2_0
+       [ComVisible(true)]
+#endif
        [Serializable]
-       [MonoTODO ("Fix serialization compatibility with MS.NET")]
        public class Stack : ICollection, IEnumerable, ICloneable {
 
                // properties
                private object[] contents;
                private int current = -1;
-               private int count = 0;
+               private int count;
                private int capacity;
-               private int modCount = 0;
+               private int modCount;
+                       
+               const int default_capacity = 16;
 
-               private void Resize(int ncapacity) {
+               private void Resize(int ncapacity)
+               {
                        
                        ncapacity = Math.Max (ncapacity, 16);
                        object[] ncontents = new object[ncapacity];
@@ -53,7 +61,11 @@ namespace System.Collections {
                        contents = ncontents;
                }
 
-               public Stack () : this (16) {}
+               public Stack ()
+               {
+                       contents = new object[default_capacity];
+                       capacity = default_capacity;
+               }
 
                public Stack(ICollection col) : this (col == null ? 16 : col.Count) {
                        if (col == null)
@@ -66,11 +78,12 @@ namespace System.Collections {
                                Push (o);
                }
 
-               public Stack (int initialCapacity) {
+               public Stack (int initialCapacity)
+               {
                        if (initialCapacity < 0)
                                throw new ArgumentOutOfRangeException ("initialCapacity");
                        
-                       capacity = Math.Max (initialCapacity, 16);
+                       capacity = initialCapacity;
                        contents = new object[capacity];
                }