Files
2026-06-04 11:42:34 +02:00

161 lines
6.8 KiB
C#

using System;
namespace System
{
/// <summary>Delimits a section of a one-dimensional array.</summary>
/// <typeparam name="T">The type of the elements in the array segment.</typeparam>
/// <filterpriority>2</filterpriority>
// Token: 0x0200063B RID: 1595
[Serializable]
public struct ArraySegment<T>
{
/// <summary>Initializes a new instance of the <see cref="T:System.ArraySegment`1" /> structure that delimits the specified range of the elements in the specified array.</summary>
/// <param name="array">The array containing the range of elements to delimit.</param>
/// <param name="offset">The zero-based index of the first element in the range.</param>
/// <param name="count">The number of elements in the range.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="offset" /> or <paramref name="count" /> is less than 0.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="offset" /> and <paramref name="count" /> do not specify a valid range in <paramref name="array" />.</exception>
// Token: 0x06003B28 RID: 15144 RVA: 0x000C9BA4 File Offset: 0x000C7DA4
public ArraySegment(T[] array, int offset, int count)
{
if (array == null)
{
throw new ArgumentNullException("array");
}
if (offset < 0)
{
throw new ArgumentOutOfRangeException("offset", "Non-negative number required.");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
}
if (offset > array.Length)
{
throw new ArgumentException("out of bounds");
}
if (array.Length - offset < count)
{
throw new ArgumentException("out of bounds", "offset");
}
this.array = array;
this.offset = offset;
this.count = count;
}
/// <summary>Initializes a new instance of the <see cref="T:System.ArraySegment`1" /> structure that delimits all the elements in the specified array.</summary>
/// <param name="array">The array to wrap.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
// Token: 0x06003B29 RID: 15145 RVA: 0x000C9C34 File Offset: 0x000C7E34
public ArraySegment(T[] array)
{
if (array == null)
{
throw new ArgumentNullException("array");
}
this.array = array;
this.offset = 0;
this.count = array.Length;
}
/// <summary>Gets the original array containing the range of elements that the array segment delimits.</summary>
/// <returns>The original array that was passed to the constructor, and that contains the range delimited by the <see cref="T:System.ArraySegment`1" />.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000B54 RID: 2900
// (get) Token: 0x06003B2A RID: 15146 RVA: 0x000C9C6C File Offset: 0x000C7E6C
public T[] Array
{
get
{
return this.array;
}
}
/// <summary>Gets the position of the first element in the range delimited by the array segment, relative to the start of the original array.</summary>
/// <returns>The position of the first element in the range delimited by the <see cref="T:System.ArraySegment`1" />, relative to the start of the original array.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000B55 RID: 2901
// (get) Token: 0x06003B2B RID: 15147 RVA: 0x000C9C74 File Offset: 0x000C7E74
public int Offset
{
get
{
return this.offset;
}
}
/// <summary>Gets the number of elements in the range delimited by the array segment.</summary>
/// <returns>The number of elements in the range delimited by the <see cref="T:System.ArraySegment`1" />.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000B56 RID: 2902
// (get) Token: 0x06003B2C RID: 15148 RVA: 0x000C9C7C File Offset: 0x000C7E7C
public int Count
{
get
{
return this.count;
}
}
/// <summary>Determines whether the specified object is equal to the current instance.</summary>
/// <returns>true if the specified object is a <see cref="T:System.ArraySegment`1" /> structure and is equal to the current instance; otherwise, false.</returns>
/// <param name="obj">The object to be compared with the current instance.</param>
// Token: 0x06003B2D RID: 15149 RVA: 0x000C9C84 File Offset: 0x000C7E84
public override bool Equals(object obj)
{
return obj is ArraySegment<T> && this.Equals((ArraySegment<T>)obj);
}
/// <summary>Determines whether the specified <see cref="T:System.ArraySegment`1" /> structure is equal to the current instance.</summary>
/// <returns>true if the specified <see cref="T:System.ArraySegment`1" /> structure is equal to the current instance; otherwise, false.</returns>
/// <param name="obj">The <see cref="T:System.ArraySegment`1" /> structure to be compared with the current instance.</param>
// Token: 0x06003B2E RID: 15150 RVA: 0x000C9CA0 File Offset: 0x000C7EA0
public bool Equals(ArraySegment<T> obj)
{
return this.array == obj.Array && this.offset == obj.Offset && this.count == obj.Count;
}
/// <summary>Returns the hash code for the current instance.</summary>
/// <returns>A 32-bit signed integer hash code.</returns>
// Token: 0x06003B2F RID: 15151 RVA: 0x000C9CDC File Offset: 0x000C7EDC
public override int GetHashCode()
{
return this.array.GetHashCode() ^ this.offset ^ this.count;
}
/// <summary>Indicates whether two <see cref="T:System.ArraySegment`1" /> structures are equal.</summary>
/// <returns>true if <paramref name="a" /> is equal to <paramref name="b" />; otherwise, false.</returns>
/// <param name="a">The <see cref="T:System.ArraySegment`1" /> structure on the left side of the equality operator.</param>
/// <param name="b">The <see cref="T:System.ArraySegment`1" /> structure on the right side of the equality operator.</param>
// Token: 0x06003B30 RID: 15152 RVA: 0x000C9CF8 File Offset: 0x000C7EF8
public static bool operator ==(ArraySegment<T> a, ArraySegment<T> b)
{
return a.Equals(b);
}
/// <summary>Indicates whether two <see cref="T:System.ArraySegment`1" /> structures are unequal.</summary>
/// <returns>true if <paramref name="a" /> is not equal to <paramref name="b" />; otherwise, false.</returns>
/// <param name="a">The <see cref="T:System.ArraySegment`1" /> structure on the left side of the inequality operator.</param>
/// <param name="b">The <see cref="T:System.ArraySegment`1" /> structure on the right side of the inequality operator.</param>
// Token: 0x06003B31 RID: 15153 RVA: 0x000C9D04 File Offset: 0x000C7F04
public static bool operator !=(ArraySegment<T> a, ArraySegment<T> b)
{
return !a.Equals(b);
}
// Token: 0x040017A7 RID: 6055
private T[] array;
// Token: 0x040017A8 RID: 6056
private int offset;
// Token: 0x040017A9 RID: 6057
private int count;
}
}