/// <summary>
        /// Re adjust the internal char buffer to justifing data after calling RemoveAt() or RemoveRange().
        /// All StringEntities are disabled after calling this function.
        /// </summary>
        public void ReAdjustment()
        {
            if (this.Length <= 0)
            {
                return;
            }

            int       gap         = 0;
            int       index_start = 1;
            ElemIndex prev_index  = this._elemIndexList[0];

            //UnityEngine.Debug.Log("elemIndexList[0]: Start = " + prev_index.Start
            //            + ", Length = " + prev_index.Length.ToString() + ", End =" + prev_index.End.ToString() );

            // this[0] is not on the head
            if (prev_index.Start > 0)
            {
                index_start = 0;
                prev_index  = new ElemIndex(0, 0);
            }

            for (int i_index = index_start; i_index < this._elemIndexList.Length; i_index++)
            {
                ElemIndex now_index = this._elemIndexList[i_index];
                gap = now_index.Start - prev_index.End;

                //    UnityEngine.Debug.Log("now_index: Start = " + now_index.Start
                //             + ", Length = " + now_index.Length.ToString() + ", End =" + now_index.End.ToString() + ", gap = " + gap.ToString());

                if (gap > 0)
                {
                    //        UnityEngine.Debug.Log("index = " + i_index
                    //           + ", shift data: [" + now_index.Start.ToString() + "-" + (now_index.End-1).ToString()
                    //            + "] -> [" + prev_index.End.ToString() + "-" + (prev_index.End+now_index.Length-1).ToString() + "]");

                    int i_start = prev_index.End;
                    for (int i_data = 0; i_data < now_index.Length; i_data++)
                    {
                        this._buff[i_start + i_data] = this._buff[now_index.Start + i_data];
                    }
                }

                prev_index = new ElemIndex(prev_index.End, now_index.Length);
                this._elemIndexList[i_index] = prev_index;
            }

            for (int i = 0; i < gap; i++)
            {
                this._buff.RemoveAtSwapBack(this._buff.Length - 1);
            }

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (gap > 0)
            {
                this.NextGen();
            }
#endif
        }
예제 #2
0
        public OneXmlNode(XComment comment, ElemIndex pos, OneXmlNode parent)
        {
            SomeInit(parent, COMMENT_NAME);
            XCommentNode = comment;
            Text         = comment.Value;

            ChildIndex = pos;
            Type       = 2;
        }
예제 #3
0
        public OneXmlNode(XElement root, ElemIndex pos = null, OneXmlNode parent = null)
        {
            SomeInit(parent, root.Name.ToString());

            Root = root;
            Text = Root.Name.ToString();
            if (pos == null)
            {
                ChildIndex = new ElemIndex("", "", 0);
            }
            else
            {
                ChildIndex = pos;
            }
            Type = 1;
        }
예제 #4
0
        static public void sortArrayByFrequency(int[] a)
        {
            var My_dic = new Dictionary <ElemIndex, int>();


            ElemIndex Ei = new ElemIndex();

            for (int i = 0; i < a.Length; i++)
            {
                Ei.Element = a[i];
                if (My_dic.ContainsKey(Ei))
                {
                    My_dic[Ei] = My_dic[Ei] + 1;
                }
                else
                {
                    My_dic.Add(new ElemIndex {
                        Element = a[i], Index = i
                    }, 1);
                }
            }
            var myList = My_dic.ToList();

            myList = myList.OrderByDescending(x => x.Value).ThenBy(x => x.Key.Index).ToList();

            int frequency = 0;

            foreach (KeyValuePair <ElemIndex, int> pair in myList)
            {
                frequency = pair.Value;
                for (int i = 0; i < frequency; i++)
                {
                    Console.Write(pair.Key.Element + "  ");
                }
            }
        }