public override bool Equals(object o) { if (o == this) { return(true); } if (!(o is Edu.Stanford.Nlp.Util.TreeShapedStack)) { return(false); } Edu.Stanford.Nlp.Util.TreeShapedStack <object> other = (Edu.Stanford.Nlp.Util.TreeShapedStack <object>)o; Edu.Stanford.Nlp.Util.TreeShapedStack <T> current = this; if (other.Size() != this.Size()) { return(false); } for (int i = 0; i < Size(); ++i) { T currentObject = current.Peek(); object otherObject = other.Peek(); if (!(currentObject == otherObject || (currentObject != null && currentObject.Equals(otherObject)))) { return(false); } other = other.Pop(); current = current.Pop(); } return(true); }
/// <summary>Returns the current stack as a list</summary> public virtual IList <T> AsList() { IList <T> result = Generics.NewArrayList(size); Edu.Stanford.Nlp.Util.TreeShapedStack <T> current = this; for (int index = 0; index < size; ++index) { result.Add(current.data); current = current.Pop(); } Java.Util.Collections.Reverse(result); return(result); }
private TreeShapedStack(Edu.Stanford.Nlp.Util.TreeShapedStack <T> previous, T data, int size) { this.previous = previous; this.data = data; this.size = size; }