Exemplo n.º 1
0
 internal override void set_list(BList <T> list)
 {
     if (this.list == list)
     {
         return;
     }
     this.list = list;
     for (int i = 0, iN = this.data.Count; i < iN; i++)
     {
         this.data[i].set_list(list);
     }
 }
Exemplo n.º 2
0
            static bool Test2()
            {
                System.Random ran = new System.Random(2134);

                {
//%%if IsEx==0 (
                    BList <int>     list1 = new BList <int>();
                    Gen::List <int> list2 = new System.Collections.Generic.List <int>();
//%%elif IsEx==1
                    BListEx <TestElement>   list1 = new BListEx <TestElement>();
                    Gen::List <TestElement> list2 = new System.Collections.Generic.List <TestElement>();
//%%)
                    const int N = 100000;
                    for (int i = 0; i < N; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list1.Count);
//%%if IsEx==0 (
                        list1.Insert(idx, i);
                        list2.Insert(idx, i);
//%%elif IsEx==1
                        TestElement e = new TestElement(i);
                        list1.Insert(idx, e);
                        list2.Insert(idx, e);
//%%)
                    }

                    for (int i = 0; i < N; i++)
                    {
                        if (list1[i] != list2[i])
                        {
                            return(false);
                        }
                    }


                    for (int i = 0; i < N / 2; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list1.Count);
                        list1.RemoveAt(idx);
                        list2.RemoveAt(idx);
                    }

                    for (int i = 0; i < N / 2; i++)
                    {
                        if (list1[i] != list2[i])
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
Exemplo n.º 3
0
            static bool Test2a()
            {
                System.Random ran = new System.Random(2134);

                {
//%%if IsEx==0 (
                    BList <int> list1 = new BList <int>();
//%%elif IsEx==1
                    BListEx <TestElement> list1 = new BListEx <TestElement>();
//%%)
                    const int N = 1000000;
                    for (int i = 0; i < N; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list1.Count);
//%%if IsEx==0 (
                        list1.Insert(idx, i);
//%%elif IsEx==1
                        TestElement e = new TestElement(i);
                        list1.Insert(idx, e);
//%%)
                        if (i % 1000 == 0)
                        {
                            list1.DbgCheckState();
                        }
                    }

                    for (int i = 0; i < N / 2; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list1.Count);
                        list1.RemoveAt(idx);
                        if (i % 1000 == 0)
                        {
                            list1.DbgCheckState();
                        }
                    }

                    list1.DbgCheckState();
                }
                return(true);
            }
Exemplo n.º 4
0
 internal virtual void set_list(BList <T> list)
 {
     this.list = list;
 }