// 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);
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");
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];
}
}
}
- 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 {
}
}
- public virtual void Push(Object o) {
+ public virtual void Push (Object obj)
+ {
modCount++;
if (capacity == count) {
count++;
current++;
- contents[current] = o;
+ contents[current] = obj;
}
public virtual object[] ToArray() {