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();

            StosWLiscie <string> s2 = new StosWLiscie <string>();

            s2.Push("km");
            s2.Push("aa");
            s2.Push("xx");
            foreach (var x in s2.ToArray())
            {
                Console.WriteLine(x);
            }

            Console.WriteLine();
        }
Beispiel #2
0
        public void Indexer_Test_Exception_Greater_Than_Length()
        {
            StosWLiscie <char> stos = new StosWLiscie <char>();

            stos.Push('a');

            char x = stos[stos.Count + 2];
        }
Beispiel #3
0
        public void Indexer_Test_Exception_Less_Than_Zero()
        {
            StosWLiscie <char> stos = new StosWLiscie <char>();

            stos.Push('a');

            char x = stos[-1];
        }
Beispiel #4
0
        public void Indexer_Test()
        {
            StosWLiscie <char> stos = new StosWLiscie <char>();

            stos.Push('a');
            stos.Push('b');

            Assert.AreEqual('a', stos[0]);
            Assert.AreEqual('b', stos[stos.Count - 1]);
        }
Beispiel #5
0
 internal EnumeratorStosu(StosWLiscie <T> stos) => this.stos = stos;
        static void Main(string[] args)
        {
            StosWTablicy <string> s = new StosWTablicy <string>();

            s.Push("km");
            s.Push("aa");
            s.Push("ab");
            s.Push("ac");
            s.Push("xx");

            foreach (var x in s)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("---top to bottom---");
            foreach (var x in ((StosWTablicy <string>)s).TopToBottom)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine($"Actual tab length: {s.GetActualTabLength()}");
            s.TrimExcess();
            Console.WriteLine($"Length after TrimExcess: {s.GetActualTabLength()}");

            Console.WriteLine($"el at position 1 (\"aa\"): {s[1]} {"aa" == s[1]}");
            Console.WriteLine();

            var sToArray         = s.ToArray();
            var sToArrayReadOnly = s.ToArrayReadOnly();

            sToArray[1] = "ssss";
            foreach (var x in sToArray)
            {
                Console.WriteLine(x);
            }
            //sToArrayReadOnly[1] = "ss"; read only error
            Console.WriteLine("---StosWLiscie---");
            StosWLiscie <int> sl = new StosWLiscie <int>();

            sl.Push(5);
            sl.Push(6);
            Console.WriteLine($"el at index 1: {sl[1]}");
            sl.Push(7);
            sl.Push(8);
            int[] tab = sl.ToArray();
            foreach (var i in tab)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine("\nPop:");
            sl.Pop();
            tab = sl.ToArray();
            foreach (var i in tab)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine();
            Console.WriteLine("foreach through StosWLiscie");
            foreach (var i in sl)
            {
                Console.Write($"{i} ");
            }
            Console.WriteLine($"\nIs array empty? {sl.IsEmpty}");
            sl.Clear();
            Console.WriteLine("After clear:");
            Console.WriteLine($"Is array empty? {sl.IsEmpty}");
        }