Esempio n. 1
0
        public static void sort_itineraries()
        {
            Itinerary[] its;
            Itinerary   it;
            int         i, n;

            if (itineraries == null)
            {
                return;
            }
            n = 0;
            for (it = itineraries; it != null; it = it.next)
            {
                ++n;
            }
            its = new Itinerary[n];
            n   = 0;
            for (it = itineraries; it != null; it = it.next)
            {
                its[n++] = it;
            }
            Array.Sort(its, 0, n, new ByName());
            for (i = 0; i < n - 1; ++i)
            {
                its[i].next = its[i + 1];
            }
            its[i].next = null;
            itineraries = its[0];
        }
Esempio n. 2
0
        public static void add_itinerary(Itinerary it, int x, int y, bool sw)
        {
            int i;

            for (i = 0; i < it.nsects; ++i)
            {
                if (it.sw[i].x == x && it.sw[i].y == y)
                {
                    it.sw[i].switched = sw;
                    return;
                }
            }
            if (it.nsects >= it.maxsects)
            {
                it.maxsects += 10;
                if (it.sw == null)
                {
                    it.sw = new switin[it.maxsects];
                }
                else
                {
                    it.sw = Globals.realloc(it.sw, it.maxsects);
                }
            }
            if (it.sw[it.nsects] == null)
            {
                it.sw[it.nsects] = new switin();
            }
            it.sw[it.nsects].x        = x;
            it.sw[it.nsects].y        = y;
            it.sw[it.nsects].switched = sw;
            ++it.nsects;
        }
Esempio n. 3
0
            public int Compare(object oa, object ob)
            {
                if (
                    ((oa is Itinerary) == false) ||
                    ((ob is Itinerary) == false)
                    )
                {
                    return(0);
                }

                Itinerary ia = (Itinerary)oa;
                Itinerary ib = (Itinerary)ob;

                if ((ia == null) || String.IsNullOrEmpty(ia.name))
                {
                    return(-1);
                }
                if ((ib == null) || String.IsNullOrEmpty(ib.name))
                {
                    return(1);
                }

                return(String.Compare(ia.name, ib.name));
            }