public static void Main(String[] args)
        {
            DoubleSpring ds = new DoubleSpring();

            Console.WriteLine("Enter Name-");
            var input = Console.ReadLine();

            ds.Add(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Add(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Add(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Add(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Add(input);
            foreach (var i in ds)
            {
                Console.WriteLine(i);
            }
        }
        public static void Main(String[] args)
        {
            DoubleSpring ds = new DoubleSpring();

            Console.WriteLine("Enter Name-");
            var input = Console.ReadLine();

            ds.Expand(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Expand(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Expand(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Expand(input);
            Console.WriteLine("Enter Name-");
            input = Console.ReadLine();
            ds.Expand(input);
            Console.WriteLine($"No of Elements-{ds.Count()}");
            foreach (var i in ds)
            {
                Console.WriteLine(i);
                Console.WriteLine("-------------");
            }
            ds.Compress();
            Console.WriteLine($"No of Elements-{ds.Count()}");
            foreach (var j in ds)
            {
                Console.WriteLine(j);
                Console.WriteLine("-------------");
            }
        }
        public static void Main(String[] args)
        {
            DoubleSpring ds = new DoubleSpring();

            ds.Add("Mallikarjuna");
            ds.Add("Ram");
            ds.Add("Arjun");
            ds.Add("Vamshi");
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine(ds[i]);
            }
        }
コード例 #4
0
        public static void Main(String[] args)
        {
            DoubleSpring <int> ds1 = new DoubleSpring <int>();

            ds1.Expand(1);
            ds1.Expand(2);
            ds1.Expand(3);
            ds1.Expand(4);
            ds1.Expand(5);
            foreach (var k in ds1)
            {
                Console.WriteLine(k);
                Console.WriteLine("-------------");
            }
            ds1.Compress();
            foreach (var k in ds1)
            {
                Console.WriteLine(k);
                Console.WriteLine("-------------");
            }
        }
 public SpringEnumerator(DoubleSpring ds)
 {
     DS    = ds;
     index = -1;
 }