Beispiel #1
0
        public static void swap(ref std_list <T> _this, ref std_list <T> _other)
        {
            std_list <T> temp = _this;

            _this  = _other;
            _other = temp;
        }
Beispiel #2
0
        //public void remove_if(Action<T> ondelete) {

        //}
        //public void resize(int size) {
        //}
        //public void resize(int size, T @defaultvalue) {

        //}


        public static void sort(ref std_list <T> sortlist)
        {
            T[]      values = sortlist.get_allocator();
            List <T> sv     = new List <T>(values);

            sv.Sort();
            std_list <T> sl = new std_list <T>(sv);

            sortlist = sl;
        }
Beispiel #3
0
        public static void reverse(ref std_list <T> _this)
        {
            T[] values = _this.get_allocator();
            int len    = values.Length;

            _this = new std_list <T>();
            foreach (var v in values)
            {
                _this.AddFirst(v);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 移除重复项目
        /// Remove duplicate values
        /// </summary>
        /// <param name="_this"></param>
        public static void unique(ref std_list <T> _this)
        {
            T[]      values = _this.get_allocator();
            List <T> ul     = new List <T>();

            foreach (var v in values)
            {
                if (!ul.Contains(v))
                {
                    ul.Add(v);
                }
            }
            _this = new std_list <T>(ul);
        }
Beispiel #5
0
        /// <summary>
        /// 内部自动排序
        /// </summary>
        /// <param name="_this"></param>
        /// <param name="_other"></param>
        public static void merge(ref std_list <T> _this, std_list <T> _other, IComparer <T> compare)
        {
            T[]      _tv = _this.get_allocator();
            T[]      _ov = _other.get_allocator();
            List <T> sv  = new List <T>();

            sv.AddRange(_tv);
            sv.AddRange(_ov);
            if (compare != null)
            {
                sv.Sort(compare);
            }
            else
            {
                sv.Sort();
            }
            _this = new std_list <T>(sv);
        }