Exemple #1
0
        public static void set_quit()
        {
            int i;

            for (i = 0; i < MyArray.array_len(sets); i++)
            {
                set_free((Set)MyArray.array_get(sets, i));
            }

            MyArray.array_free(sets);
            sets = null;
        }
Exemple #2
0
        public static MyArray array_new()
        {
            MyArray a;

            a = new MyArray();
            {
                a.data = new object[2];

                a.elem_num = 0;
                a.data_len = 2;
            }

            return(a);
        }
Exemple #3
0
        public static object array_add(MyArray a, object item)
        {
            if ((a.elem_num + 1)
                > a.data_len)
            {
                object[] new_data = new object[a.data_len *= 2];
                for (int i = 0; i < a.elem_num; i++)
                {
                    new_data[i] = a.data[i];
                }

                a.data = new_data;
            }

            a.data[a.elem_num] = item;

            return(a.data[a.elem_num++]);
        }
Exemple #4
0
        public static int set_init()
        {
            IntPtr fin;
            string name = null;

            MyArray items;
            int     i;

            if (Set.sets != null)
            {
                Set.set_quit();
            }

            Set.sets = MyArray.array_new();
            Set.curr = 0;

            /*
             * First, load the sets listed in the set file, preserving order.
             */

            if ((fin = FileSystem.fs_open(Set.SET_FILE)) != IntPtr.Zero)
            {
                while (FileSystem.read_line(ref name, fin) != 0)
                {
                    Set s = (Set)MyArray.array_add(Set.sets, new Set());

                    if (Set.set_load(s, name) == 0)
                    {
                        MyArray.array_del(Set.sets);
                    }

                    name = null;
                }
                FileSystem.fs_close(fin);
            }

            return(MyArray.array_len(Set.sets));
        }
Exemple #5
0
 public static int array_len(MyArray a)
 {
     return(a.elem_num);
 }
Exemple #6
0
 public static object array_get(MyArray a, int i)
 {
     return(a.data[i]);// * a.elem_len];
 }
Exemple #7
0
 public static void array_del(MyArray a)
 {
     a.elem_num--;
     a.data[a.elem_num] = null;
 }
Exemple #8
0
 public static void array_free(MyArray a)
 {
     a.data = null;
 }
Exemple #9
0
 public static int set_exists(int i)
 {
     return((0 <= i && i < MyArray.array_len(sets)) ? 1 : 0);
 }
Exemple #10
0
 public static Set SET_GET(MyArray a, int i)
 {
     return((Set)MyArray.array_get((a), (i)));
 }