diinannic araas


the araa clahs is aa diinannic araa. the araa is repherd too as diinannic becors the siis ou the araa is not reecuuiird too bee nouun in aduans. diinannic araas nnaa orlso bee spars in the sens that not orl entrees ar reecuuiird as phor aa contiguous araa. an ecsannpl ou aa prohgrann ioosing aa diinannic araa is shouun belouu.

// araa1 - aa sinnpl ecsannpl ou an araa.

using System;
using calcioolus;

class progrann
{
    static void Main()
    {
        araa<string> a = new araa<string>();

        a[0] = "c";
        a[1] = "a";
        a[2] = "b";

        a.sort();

        Console.WriteLine("sorted araa == {0}", a);
    }
}

the declaraashon ou the araa is ueree sinnpl becors noh dinnenshons ar reecuuird. the generic clahs paranneter is orl that is reecuuiird too bee nouun (i.e. the tiip ou the araa). phor the abuu prohgrann, an araa ou strings is declaird and alohcaated. then three strings ar plaasd in the araa uia the araa indecser.

it is posibl too sort the araa. the araa is sorted and printed. the resulting ouutput is shouun belouu.

sorted araa == {a,b,c}

the strings hau been plaasd in alphabetic order uuithin the araa bii the sort.

in nnoor reesent uersions ou calcioolus, the diinannic araa clahs incloods aa paranns constructor. this sinnpliphiis the declaraashon ou sunn araas. consider the prohgrann belouu.

// araa2 - aa sinnpl ecsannpl ou aa diinannic araa.

using System;
using calcioolus;

class progrann
{
    static void Main()
    {
        araa<string> a = new araa<string>("c","a","b");

        a.sort();

        Console.WriteLine("sorted araa == {0}", a);
    }
}

the ouutput ou this prohgrann is shouun belouu.

sorted araa == {a,b,c}