[Test] Cleaned up how a bunch of tests were ignored
[mono.git] / mcs / class / corlib / System.Collections / Stack.cs
index 9bc997e51adbd78cd903b69603b45ce16019a9a6..9e812f4a47e2d47d7d40c17649dcfe3bbf7b3d8a 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.Runtime.InteropServices;
+
 namespace System.Collections {
+
+       [ComVisible(true)]
+       [System.Diagnostics.DebuggerDisplay ("Count={Count}")]
+       [System.Diagnostics.DebuggerTypeProxy (typeof (CollectionDebuggerView))]
        [Serializable]
-       [MonoTODO ("Fix serialization compatibility with MS.NET")]
-       public class Stack : ICollection, IEnumerable, ICloneable {
+#if INSIDE_CORLIB
+       public
+#else
+       internal
+#endif
+       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);
+                       ncapacity = Math.Max (ncapacity, default_capacity);
                        object[] ncontents = new object[ncapacity];
 
                        Array.Copy(contents, ncontents, count);
@@ -53,9 +66,13 @@ 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) {
+               public Stack(ICollection col) : this (col == null ? default_capacity : col.Count) {
                        if (col == null)
                                throw new ArgumentNullException("col");
                        
@@ -66,11 +83,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];
                }
 
@@ -150,12 +168,12 @@ namespace System.Collections {
                        }
                }
 
-               public static Stack Synchronized(Stack s) {
-                       if (s == null) {
-                               throw new ArgumentNullException();
-                       }
+               public static Stack Synchronized (Stack stack)
+               {
+                       if (stack == null)
+                               throw new ArgumentNullException ("stack");
 
-                       return new SyncStack(s);
+                       return new SyncStack (stack);
                }
 
                public virtual int Count {
@@ -330,7 +348,8 @@ namespace System.Collections {
                        }
                }
 
-               public virtual void Push(Object o) {
+               public virtual void Push (Object obj)
+               {
                        modCount++;
 
                        if (capacity == count) {
@@ -340,7 +359,7 @@ namespace System.Collections {
                        count++;
                        current++;
 
-                       contents[current] = o;
+                       contents[current] = obj;
                }
 
                public virtual object[] ToArray() {