예제 #1
0
        public static DateTime[] ReadDates()
        {
            FixCapacityStack<DateTime> stack = new FixCapacityStack<DateTime>(32);
            DateTime date = new DateTime(2013, 1, 31);
            for (int i = 30; i >= 0; i--)
            {
                stack.Push(date);
                date = date.AddDays(-1);
            }

            ResizingQueue<DateTime> queue = new ResizingQueue<DateTime>();

            while (!stack.IsEmpty())
                queue.Enqueue(stack.Pop());

            int size = queue.Size;
            DateTime[] dates = new DateTime[size];
            for (int i = 0; i < size; i++)
            {
                dates[i] = queue.Dequeue();
            }

            return dates;
        }
예제 #2
0
        private static void PrintBinaryPresentation(int number)
        {
            FixCapacityStack<int> stack = new FixCapacityStack<int>(number);
            while (number > 0)
            {
                stack.Push(number % 2);
                number = number / 2;
            }

            while (!stack.IsEmpty())
            {
                Debug.Write(stack.Pop());
            }

            Debug.WriteLine("");
        }
예제 #3
0
        public void E1317()
        {
            FixCapacityStack<Transaction> stack = new FixCapacityStack<Transaction>(60);
            ResizingQueue<Transaction> queue = new ResizingQueue<Transaction>();

            for (int i = 0; i < 31; i++)
            {
                stack.Push(new Transaction(string.Format("name{0}", i), new Date(2013, 1, i + 1), i));
            }

            while (!stack.IsEmpty())
                queue.Enqueue(stack.Pop());

            int size = queue.Size;
            for (int i = 0; i < size; i++)
            {
                Debug.WriteLine(queue.Dequeue());
            }
        }