public int SearchLastSegment(SearchMarkState <T> state) { if (m_Segments.Count <= 0) { return(-1); } ArraySegmentEx <T> arraySegmentEx = m_Segments[m_Segments.Count - 1]; if (arraySegmentEx == null) { return(-1); } int?num = arraySegmentEx.Array.SearchMark(arraySegmentEx.Offset, arraySegmentEx.Count, state.Mark); if (!num.HasValue) { return(-1); } if (num.Value > 0) { state.Matched = 0; return(num.Value - arraySegmentEx.Offset + arraySegmentEx.From); } state.Matched = -num.Value; return(-1); }
// Token: 0x0600066A RID: 1642 RVA: 0x0001A8EC File Offset: 0x00018AEC public void DecodeMask(byte[] mask, int offset, int length) { int num = mask.Length; int num2 = 0; ArraySegmentEx <byte> arraySegmentEx = base.QuickSearchSegment(0, base.Segments.Count - 1, offset, out num2); int num3 = Math.Min(length, arraySegmentEx.Count - offset + arraySegmentEx.From); int num4 = offset - arraySegmentEx.From + arraySegmentEx.Offset; int num5 = 0; for (int i = num4; i < num4 + num3; i++) { arraySegmentEx.Array[i] = (arraySegmentEx.Array[i] ^ mask[num5++ % num]); } if (num5 >= length) { return; } for (int j = num2 + 1; j < base.SegmentCount; j++) { ArraySegmentEx <byte> arraySegmentEx2 = base.Segments[j]; num3 = Math.Min(length - num5, arraySegmentEx2.Count); for (int k = arraySegmentEx2.Offset; k < arraySegmentEx2.Offset + num3; k++) { arraySegmentEx2.Array[k] = (arraySegmentEx2.Array[k] ^ mask[num5++ % num]); } if (num5 >= length) { return; } } }
public T[] ToArrayData(int startIndex, int length) { T[] array = new T[length]; int num = 0; int num2 = 0; int num3 = 0; int segmentIndex = 0; if (startIndex != 0) { ArraySegmentEx <T> arraySegmentEx = QuickSearchSegment(0, m_Segments.Count - 1, startIndex, out segmentIndex); num = startIndex - arraySegmentEx.From; if (arraySegmentEx == null) { throw new IndexOutOfRangeException(); } } for (int i = segmentIndex; i < m_Segments.Count; i++) { ArraySegmentEx <T> arraySegmentEx2 = m_Segments[i]; num2 = Math.Min(arraySegmentEx2.Count - num, length - num3); Array.Copy(arraySegmentEx2.Array, arraySegmentEx2.Offset + num, array, num3, num2); num3 += num2; if (num3 >= length) { break; } num = 0; } return(array); }
public ArraySegmentEx <T> QuickSearchSegment(int from, int to, int index, out int segmentIndex) { segmentIndex = -1; int num = to - from; switch (num) { case 0: { ArraySegmentEx <T> arraySegmentEx = m_Segments[from]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = from; return(arraySegmentEx); } return(null); } case 1: { ArraySegmentEx <T> arraySegmentEx = m_Segments[from]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = from; return(arraySegmentEx); } arraySegmentEx = m_Segments[to]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = to; return(arraySegmentEx); } return(null); } default: { int num2 = from + num / 2; ArraySegmentEx <T> arraySegmentEx = m_Segments[num2]; if (index >= arraySegmentEx.From) { if (index <= arraySegmentEx.To) { segmentIndex = num2; return(arraySegmentEx); } return(QuickSearchSegment(num2 + 1, to, index, out segmentIndex)); } return(QuickSearchSegment(from, num2 - 1, index, out segmentIndex)); } } }
public void AddSegment(T[] array, int offset, int length, bool toBeCopied) { if (length > 0) { int count = m_Count; ArraySegmentEx <T> arraySegmentEx = null; arraySegmentEx = (toBeCopied ? new ArraySegmentEx <T>(array.CloneRange(offset, length), 0, length) : new ArraySegmentEx <T>(array, offset, length)); arraySegmentEx.From = count; m_Count = count + arraySegmentEx.Count; arraySegmentEx.To = m_Count - 1; m_Segments.Add(arraySegmentEx); } }
// Token: 0x06000669 RID: 1641 RVA: 0x0001A7B8 File Offset: 0x000189B8 public string Decode(Encoding encoding, int offset, int length) { if (length == 0) { return(string.Empty); } IList <ArraySegmentEx <byte> > segments = base.Segments; if (segments == null || segments.Count <= 0) { return(string.Empty); } char[] array = new char[encoding.GetMaxCharCount(base.Count)]; int num = 0; int num2 = 0; int num3 = segments.Count - 1; bool flush = false; Decoder decoder = encoding.GetDecoder(); int num4 = 0; if (offset > 0) { base.QuickSearchSegment(0, segments.Count - 1, offset, out num4); } for (int i = num4; i < segments.Count; i++) { ArraySegmentEx <byte> arraySegmentEx = segments[i]; if (i == num3) { flush = true; } int byteIndex = arraySegmentEx.Offset; int num5 = Math.Min(length - num, arraySegmentEx.Count); if (i == num4 && offset > 0) { byteIndex = offset - arraySegmentEx.From + arraySegmentEx.Offset; num5 = Math.Min(arraySegmentEx.Count - offset + arraySegmentEx.From, num5); } int num6; int num7; bool flag; decoder.Convert(arraySegmentEx.Array, byteIndex, num5, array, num2, array.Length - num2, flush, out num6, out num7, out flag); num2 += num7; num += num6; if (num >= length) { break; } } return(new string(array, 0, num2)); }
// Token: 0x06000653 RID: 1619 RVA: 0x0001A330 File Offset: 0x00018530 public ArraySegmentEx <T> QuickSearchSegment(int from, int to, int index, out int segmentIndex) { segmentIndex = -1; int num = to - from; if (num == 0) { ArraySegmentEx <T> arraySegmentEx = this.m_Segments[from]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = from; return(arraySegmentEx); } return(null); } else if (num == 1) { ArraySegmentEx <T> arraySegmentEx = this.m_Segments[from]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = from; return(arraySegmentEx); } arraySegmentEx = this.m_Segments[to]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segmentIndex = to; return(arraySegmentEx); } return(null); } else { int num2 = from + num / 2; ArraySegmentEx <T> arraySegmentEx = this.m_Segments[num2]; if (index < arraySegmentEx.From) { return(this.QuickSearchSegment(from, num2 - 1, index, out segmentIndex)); } if (index <= arraySegmentEx.To) { segmentIndex = num2; return(arraySegmentEx); } return(this.QuickSearchSegment(num2 + 1, to, index, out segmentIndex)); } }
public void RemoveSegmentAt(int index) { ArraySegmentEx <T> arraySegmentEx = m_Segments[index]; int num = arraySegmentEx.To - arraySegmentEx.From + 1; m_Segments.RemoveAt(index); m_PrevSegment = null; if (index != m_Segments.Count) { for (int i = index; i < m_Segments.Count; i++) { m_Segments[i].From -= num; m_Segments[i].To -= num; } } m_Count -= num; }
public int IndexOf(T item) { int num = 0; for (int i = 0; i < m_Segments.Count; i++) { ArraySegmentEx <T> arraySegmentEx = m_Segments[i]; int offset = arraySegmentEx.Offset; for (int j = 0; j < arraySegmentEx.Count; j++) { if (arraySegmentEx.Array[j + offset].Equals(item)) { return(num); } num++; } } return(-1); }
// Token: 0x06000664 RID: 1636 RVA: 0x0001A5C4 File Offset: 0x000187C4 public void TrimEnd(int trimSize) { if (trimSize <= 0) { return; } int num = this.Count - trimSize - 1; for (int i = this.m_Segments.Count - 1; i >= 0; i--) { ArraySegmentEx <T> arraySegmentEx = this.m_Segments[i]; if (arraySegmentEx.From <= num && num < arraySegmentEx.To) { arraySegmentEx.To = num; this.m_Count -= trimSize; return; } this.RemoveSegmentAt(i); } }
// Token: 0x0600065F RID: 1631 RVA: 0x0001A4AC File Offset: 0x000186AC public void AddSegment(T[] array, int offset, int length, bool toBeCopied) { if (length <= 0) { return; } int count = this.m_Count; ArraySegmentEx <T> arraySegmentEx; if (!toBeCopied) { arraySegmentEx = new ArraySegmentEx <T>(array, offset, length); } else { arraySegmentEx = new ArraySegmentEx <T>(array.CloneRange(offset, length), 0, length); } arraySegmentEx.From = count; this.m_Count = count + arraySegmentEx.Count; arraySegmentEx.To = this.m_Count - 1; this.m_Segments.Add(arraySegmentEx); }
public int CopyTo(T[] to, int srcIndex, int toIndex, int length) { int num = 0; int num2 = 0; ArraySegmentEx <T> arraySegmentEx; int segmentIndex; if (srcIndex > 0) { arraySegmentEx = QuickSearchSegment(0, m_Segments.Count - 1, srcIndex, out segmentIndex); } else { arraySegmentEx = m_Segments[0]; segmentIndex = 0; } int num3 = srcIndex - arraySegmentEx.From + arraySegmentEx.Offset; num2 = Math.Min(arraySegmentEx.Count - num3 + arraySegmentEx.Offset, length - num); Array.Copy(arraySegmentEx.Array, num3, to, num + toIndex, num2); num += num2; if (num >= length) { return(num); } for (int i = segmentIndex + 1; i < m_Segments.Count; i++) { ArraySegmentEx <T> arraySegmentEx2 = m_Segments[i]; num2 = Math.Min(arraySegmentEx2.Count, length - num); Array.Copy(arraySegmentEx2.Array, arraySegmentEx2.Offset, to, num + toIndex, num2); num += num2; if (num >= length) { break; } } return(num); }
public void ClearSegements() { m_Segments.Clear(); m_PrevSegment = null; m_Count = 0; }
private int GetElementpublicIndex(int index, out ArraySegmentEx <T> segment) { segment = null; if (index < 0 || index > Count - 1) { return(-1); } if (index == 0) { m_PrevSegment = m_Segments[0]; m_PrevSegmentIndex = 0; segment = m_PrevSegment; return(m_PrevSegment.Offset); } int num = 0; if (m_PrevSegment != null) { if (index >= m_PrevSegment.From) { if (index <= m_PrevSegment.To) { segment = m_PrevSegment; return(m_PrevSegment.Offset + index - m_PrevSegment.From); } num = 1; } else { num = -1; } } int num2; int to; if (num != 0) { num2 = m_PrevSegmentIndex + num; ArraySegmentEx <T> arraySegmentEx = m_Segments[num2]; if (index >= arraySegmentEx.From && index <= arraySegmentEx.To) { segment = arraySegmentEx; return(arraySegmentEx.Offset + index - arraySegmentEx.From); } num2 += num; ArraySegmentEx <T> arraySegmentEx2 = m_Segments[num2]; if (index >= arraySegmentEx2.From && index <= arraySegmentEx2.To) { m_PrevSegment = arraySegmentEx2; m_PrevSegmentIndex = num2; segment = arraySegmentEx2; return(arraySegmentEx2.Offset + index - arraySegmentEx2.From); } if (num > 0) { num2++; to = m_Segments.Count - 1; } else { int num3 = num2 - 1; num2 = 0; to = num3; } } else { num2 = 0; to = m_Segments.Count - 1; } int segmentIndex = -1; ArraySegmentEx <T> arraySegmentEx3 = QuickSearchSegment(num2, to, index, out segmentIndex); if (arraySegmentEx3 != null) { m_PrevSegment = arraySegmentEx3; m_PrevSegmentIndex = segmentIndex; segment = m_PrevSegment; return(arraySegmentEx3.Offset + index - arraySegmentEx3.From); } m_PrevSegment = null; return(-1); }