示例#1
0
        /// <summary>
        /// 按照新的名称,排列组织数组
        /// </summary>
        /// <param name="newColNames"></param>
        /// <param name="defaultNewVal"></param>
        public void ArrangeCols(List <string> newColNames, double defaultNewVal = 0)
        {
            //首先,在老矩阵中删除新矩阵没有的行或列
            var colNamesTobeRemoved = Geo.Utils.ListUtil.GetExcept <string>(ColNames, newColNames);

            RemoveCol(colNamesTobeRemoved);

            int icol = 0;

            foreach (var name in newColNames)
            {
                if (ColNames.Contains(name))//若包含
                {
                    var index = (ColNames.IndexOf(name));
                    if (index != icol)          //但非同一行
                    {
                        ChangeCol(icol, index); //交换之
                    }
                }
                else
                {
                    InsertCol(icol, name, defaultNewVal);
                }
                icol++;
            }
        }
示例#2
0
        /// <summary>
        /// 移除列
        /// </summary>
        /// <param name="name"></param>
        public void RemoveCol(string name)
        {
            int index = ColNames.IndexOf(name);

            RemoveCol(index);
        }