コード例 #1
0
        internal FMultiRngString(string str, int sidx, int eidx, FMultiRngString next) : this(str, sidx, eidx)
        {
            this.next = next;
            last      = next;

            next.last = null;
        }
コード例 #2
0
            public bool MoveNext()
            {
                if (str == null)
                {
                    str = curr.str;
                }
                else if (++cidx < eidx)
                {
                    FMultiRngString next = curr.next;
                    if (next != null)
                    {
                        curr = next;

                        str =
                            joinCharacter > 0
                            ? null
                            : next.str;

                        cidx = next.sidx;
                        eidx = next.eidx;
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(true);
            }
コード例 #3
0
        public bool ValueEquals(FMultiRngString other)
        {
            if (this == other)
            {
                return(true);
            }
            else if (other == null)
            {
                return(false);
            }

            FMultiRngString left = this;

            do
            {
                if (left.next == null != (other.next == null))
                {
                    return(false);
                }

                if (left.str != other.str ||
                    left.sidx != other.sidx ||
                    left.eidx != other.eidx)
                {
                    return(false);
                }

                left  = left.next;
                other = other.next;
            }while (left != null);

            return(true);
        }
コード例 #4
0
        internal FMultiRngString(string str, int sidx, int eidx)
        {
            this.str  = str;
            this.sidx = sidx;
            this.eidx = eidx;

            next = this;
            last = this;
        }
コード例 #5
0
        private void AddLastInternal(FMultiRngString add)
        {
            FMultiRngString lastNode = last;

            lastNode.next = add;

            last     = add;
            add.last = null;
        }
コード例 #6
0
            public void Reset()
            {
                FMultiRngString first = this.first;

                cidx = first.sidx - 1;
                eidx = first.eidx;
                str  = first.str;

                curr = first;
            }
コード例 #7
0
            public Enumerator(FMultiRngString first, char joinCharacter)
            {
                this.first         = first;
                this.joinCharacter = joinCharacter;

                str  = first.str;
                cidx = first.sidx - 1;
                eidx = first.eidx;

                curr = first;
            }
コード例 #8
0
        public override int GetHashCode()
        {
            int sidx     = this.sidx;
            int hashcode = str.GetFixedHashcode(sidx, eidx - sidx);

            for (FMultiRngString n = next; n != null; n = n.next)
            {
                sidx     = n.sidx;
                hashcode = IntHash.CombineMOD(hashcode, str.GetFixedHashcode(sidx, n.eidx - sidx));
            }

            return(hashcode);
        }
コード例 #9
0
        /// <summary>
        /// Caculate total nodes count & string length
        /// </summary>
        /// <returns>nodes count, total string length</returns>
        public void FullSize(out int nodes, out int totalLength)
        {
            int sidx = this.sidx;
            int eidx = this.eidx;

            int length = eidx - sidx;
            int cnt    = 0;

            FMultiRngString t = next;

            for (; t != null; t = t.next)
            {
                cnt++;
                length += t.eidx - t.sidx;
            }

            nodes       = cnt;
            totalLength = length;
        }
コード例 #10
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                str  = null;
                sidx = 0;
                eidx = 0;
            }

            // 모든 레퍼런스를 삭제
            FMultiRngString p = this;

            while (p.next != null)
            {
                FMultiRngString n = p.next;
                p.next = null;

                p = n;
            }
        }
コード例 #11
0
        public string ToString(char joinCharacter)
        {
            FullSize(out int nodes, out int len);

            StringBuilder sb = new StringBuilder(nodes + len);

            ApeendTo(sb);

            FMultiRngString t = next;

            for (; t != null; t = t.next)
            {
                if (joinCharacter > 0)
                {
                    sb.Append(joinCharacter);
                }

                t.ApeendTo(sb);
            }

            return(sb.ToString());
        }
コード例 #12
0
 public void Dispose()
 {
     first = null;
     curr  = null;
     str   = null;
 }