Exemple #1
0
 public JacketForAwardsEnumerator(JacketForAwards jacket)
 {
     this.jacket      = jacket;
     this.index       = -1;
     this.current     = default(Tuple <string, int>);
     this.__prevIndex = 0;
 }
Exemple #2
0
 public void Dispose()
 {
     this.jacket      = null;
     this.index       = -1;
     this.current     = default(Tuple <string, int>);
     this.__prevIndex = 0;
 }
Exemple #3
0
        static void Test4_CustomCollection()
        {
            // Testing a custom collection of objects.

            // Test4.1: test an indexer.
            JacketForAwards j1 = new JacketForAwards();

            j1.Add(new Tuple <string, int>("the best ever", 5));
            Console.WriteLine(j1["0x05"]);

            Tuple <string, int> tmp = new Tuple <string, int>("the second tuple", 15);

            j1.Add(tmp);
            Console.WriteLine(j1["0x0F"]);

            // Test 4.2: sorting.
            JacketForAwards j2 = new JacketForAwards();

            j2.Add(new Tuple <string, int>("the third tuple", 100));
            j2.Add(new Tuple <string, int>("the fifth tuple", 50));
            j2.Add(new Tuple <string, int>("the fifth tuple", 75));
            j2.Add(new Tuple <string, int>("the sixth tuple", -25));
            j2.Add(new Tuple <string, int>("the seventh tuple", 12));
            j2.Add(new Tuple <string, int>("the fourth tuple", -25));
            JacketForAwards j3 = new JacketForAwards();

            j3.Add(new Tuple <string, int>("the fifth tuple", 0));
            j3.Add(new Tuple <string, int>("the sixth tuple", -25));
            j3.Add(new Tuple <string, int>("the seventh tuple", 12));
            List <JacketForAwards> jList = new List <JacketForAwards>();

            jList.Add(j1);
            jList.Add(j2);
            jList.Add(j3);
            jList.Sort();
            foreach (var jacket in jList)
            {
                Console.WriteLine(jacket);
            }

            // Test 4.3.: cycling through collection.
            foreach (var tpl_awards in j2)
            {
                Console.WriteLine(tpl_awards);
            }

            // Test 4.4.: collection extension.
            // Clearing JacketForAwards j2.
            j2.Clear("This method is extended.");
        }