public HTMLParserResult Pop() { int index = this.Count - 1; if (index < 0) throw new InvalidOperationException("Empty Stack"); HTMLParserResult value = this.InnerList[index]; this.InnerList.RemoveAt(index); return value; }
public int IndexOf(string name) { for (int i = this.InnerList.Count - 1; i >= 0; i--) { HTMLParserResult item = this.InnerList[i]; if (item.Valid && (name == item.Value)) { return i; } } return -1; }
public HTMLParserResult[] PopToTag(string name) { int index = this.IndexOf(name); if (index < 0) throw new IndexOutOfRangeException("A result with the specified type (and optional value) does not exist in this stack"); HTMLParserResult[] all = new HTMLParserResult[this.Count - index]; int pos = all.Length - 1; while (this.Count > index) { all[pos] = this.Pop(); pos--; } return all; }
public int Push(HTMLParserResult result) { int index = this.InnerList.Count; this.InnerList.Add(result); return index; }