예제 #1
0
 public void Free()
 {
     if (_onAuto != null)
     {
         Globals.delete(_onAuto);
     }
     if (_onCleared != null)
     {
         Globals.delete(_onCleared);
     }
     if (_onShunt != null)
     {
         Globals.delete(_onShunt);
     }
     if (_onClick != null)
     {
         Globals.delete(_onClick);
     }
     if (_onCross != null)
     {
         Globals.delete(_onCross);
     }
     if (_onInit != null)
     {
         Globals.delete(_onInit);
     }
     if (_onUpdate != null)
     {
         Globals.delete(_onUpdate);
     }
 }
예제 #2
0
        //	Allocate enough entries to store 'maxInstances' items.
        //	This is useful when a Array must be copied into another
        //	Array, to avoid unnecessary realloc() calls.

        public void Reserve(int maxInstances)
        {
            if (_maxInstances >= maxInstances)
            {
                return;
            }
            if (_instances == null || _instances.Length == 0)
            {
                _instances = new T[maxInstances]; //(T *)malloc(maxInstances * sizeof(T));
            }
            else
            {
                T[] insts = new T[maxInstances];
                for (int xx = 0; xx < _nInstances; ++xx)
                {
                    insts[xx] = _instances[xx];
                }
                Globals.delete(_instances);
                _instances = insts;
                //		_instances = (T *)realloc(_instances, maxInstances * sizeof(T));
            }
            if (_instances == null || _instances.Length == 0)
            {
                Globals.Panic("out of memory");
            }
            _maxInstances = maxInstances;
        }
예제 #3
0
        //	Add an item to the set

        public void Add(T item)
        {
            if (_nInstances >= _maxInstances)
            {
                _maxInstances += Array_INCREMENT;

                if (_instances == null || _instances.Length == 0)
                {
                    _instances = new T[_maxInstances];
                }
                else
                {
                    T[] insts = new T[_maxInstances];
                    for (int xx = 0; xx < _nInstances; ++xx)
                    {
                        insts[xx] = _instances[xx];
                    }
                    Globals.delete(_instances);
                    _instances = insts;
                }
                if (_instances == null || _instances.Length == 0)
                {
                    Globals.Panic("out of memory");
                }

                // Erik: Disabled following line
                // memset(_instances + _maxInstances - Array_INCREMENT,
                //     0, Array_INCREMENT * sizeof(T));
            }
            _instances[_nInstances++] = item;
        }
예제 #4
0
 public void Clear()
 {
     while (_firstItem != null)
     {
         _lastItem = _firstItem._next;
         Globals.delete(_firstItem);
         _firstItem = _lastItem;
     }
 }
예제 #5
0
 public void Release()
 {
     if (_instances != null && _instances.Length > 0)
     {
         Globals.delete(_instances);
     }
     _nInstances   = 0;
     _maxInstances = 0;
     _instances    = null;
 }
예제 #6
0
        //	Delete all objects contained in the Array,
        //	effectively releasing all memory used by the Array.
        //	This can only be called when the Array "owns"
        //	the objects stored in it.

        public void DeleteAll()
        {
            int i;

            for (i = _nInstances - 1; i >= 0; --i)
            {
                Globals.delete(_instances[i]);
            }
            Release();
        }
예제 #7
0
 public void Clear()
 {
     while (_firstItem != null)
     {
         T obj = _firstItem;
         _firstItem = obj._next;
         Globals.delete(obj);
     }
     _firstItem = _lastItem = null;
     _nItems    = 0;
 }
예제 #8
0
        public void DeleteAt(int pos)
        {
            if (pos >= base.Length())
            {
                return;
            }

            T item = base.At(pos);

            base.RemoveAt(pos);
            Globals.delete(item);
        }
예제 #9
0
        static CSVFile exists(string rootDir, string fileName)
        {
            string  path;
            CSVFile csv;

            path = String.Format(wxPorting.T("%s/%s.txt"), rootDir, fileName);
            csv  = new CSVFile(path);
            if (csv.Load())
            {
                return(csv);
            }
            Globals.delete(csv);
            return(null);
        }