public T this[int index]
        {
            get
            {
                if (index < 0 || index > Count - 1)
                {
                    throw new IndexOutOfRangeException();
                }

                if (m_PrevSegment != null)
                {
                    if (index >= m_PrevSegment.From && index <= m_PrevSegment.To)
                    {
                        return(m_PrevSegment.Segment.Array[m_PrevSegment.Segment.Offset + index - m_PrevSegment.From]);
                    }
                }

                for (int i = 0; i < m_Segments.Count; i++)
                {
                    var segment = m_Segments[i];
                    if (index >= segment.From && index <= segment.To)
                    {
                        m_PrevSegment = segment;
                        return(segment.Segment.Array[segment.Segment.Offset + index - segment.From]);
                    }
                }

                throw new IndexOutOfRangeException();
            }
            set
            {
                throw new NotSupportedException();
            }
        }
        public void RemoveSegmentAt(int index)
        {
            var removedSegment = m_Segments[index];
            int removedLen     = removedSegment.To - removedSegment.From + 1;

            m_Segments.RemoveAt(index);

            m_PrevSegment = null;

            //the removed item is not the the last item
            if (index != m_Segments.Count)
            {
                for (int i = index; i < m_Segments.Count; i++)
                {
                    m_Segments[i].From -= removedLen;
                    m_Segments[i].To   -= removedLen;
                }
            }

            m_Count -= removedLen;
        }
 public void ClearSegements()
 {
     m_Segments.Clear();
     m_PrevSegment = null;
     m_Count       = 0;
 }