Пример #1
0
        /*
         * Events and Generics
         */

        static void case_7()
        {
            var buffer = new CircularBuffer <double>(capacity: 3);

            buffer.ItemDiscarded += Buffer_ItemDiscarded;
            buffer.Write(3.5);
            buffer.Write(2.4);
            buffer.Write(5.4);
            buffer.Write(8);
        }
Пример #2
0
        static void case_1()
        {
            var buffer = new CircularBuffer <double>(5);

            buffer.Write(1);
            buffer.Write(2);
            buffer.Write(3);
            buffer.Write(4);

            foreach (var item in buffer)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Buffer Count : {0}", buffer.Count);
        }
Пример #3
0
        private static void ProcessInput(CircularBuffer <double> buffer)
        {
            while (true)
            {
                var value = 0.0;
                var input = Console.ReadLine();

                if (double.TryParse(input, out value))
                {
                    buffer.Write(value);
                    continue;
                }
                break;
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            var buffer = new CircularBuffer(capacity: 3);
            while (true)
            {
                var parsed = false;
                var value = 0.0;
                var input = Console.ReadLine();

                if (double.TryParse(input, out value))
                {
                    buffer.Write(value);
                }
                break;
            }
            Console.WriteLine("Buffer ");
            while (!buffer.IsEmpty)
            {
                Console.WriteLine("\t" + buffer.Read());

            }
        }