static void Main(string[] args) { StosWLiscie <string> s = new StosWLiscie <string>(); s.Push("km"); s.Push("aa"); s.Push("xx"); s.Push("abc"); Console.WriteLine("Długość stosu"); Console.WriteLine(s.Count); Console.WriteLine(); Console.WriteLine("Indexer"); Console.WriteLine(s[0]); Console.WriteLine(); Console.WriteLine("Iterator, ToArray"); string[] tabPrzed = s.ToArray(); s.Pop(); s.Push("działa"); string[] tabPo = s.ToArray(); foreach (var x in tabPrzed) { Console.WriteLine(x); } Console.WriteLine(); foreach (var x in tabPo) { Console.WriteLine(x); } }
static void Main(string[] args) { /*StosWTablicy<string> s = new StosWTablicy<string>(2); * s.Push("km"); * s.Push("aa"); * s.Push("xx"); * foreach (var x in s.ToArray()) * Console.WriteLine(x); * * Console.WriteLine(); * * IStos<char> stos = new StosWTablicy<char>(); * * foreach (var x in ((StosWTablicy<char>)stos).TopToBottom) * { * Console.WriteLine(x); * } * * for (int i = 0; i < s.Count; i++) * Console.WriteLine(s[i]); * * Console.WriteLine("------------------"); * * Console.WriteLine("Count of elements in the Stack = " + s.Count); * s.Clear(); * s.TrimExcess(); * Console.WriteLine("Count of elements in the Stack (updated) = " + s.Count); * * Console.WriteLine("--------- Linked List ---------"); * * StosWLiscie<string> l = new StosWLiscie<string>(); * l.Push("km"); * l.Push("aa"); * l.Push("xx"); * * foreach (var x in l) * { * Console.WriteLine(x); * }*/ var stos = new StosWLiscie <char>(); char e = 'a'; Console.WriteLine(stos.IsEmpty); stos.Push(e); Console.WriteLine(e + " == " + stos.Peek); }