示例#1
0
        public unsafe NativeSliceBurst(NativeSliceBurst <T> slice, int start, int length)
        {
            #if COLLECTIONS_CHECKS
            if (start < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(start), string.Format("Slice start {0} < 0.", (object)start));
            }

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length), string.Format("Slice length {0} < 0.", (object)length));
            }

            if (start + length > slice.Length)
            {
                throw new ArgumentException(string.Format("Slice start + length ({0}) range must be <= slice.Length ({1})", (object)(start + length), (object)slice.Length));
            }

            if ((slice.m_MinIndex != 0 || slice.m_MaxIndex != slice.m_Length - 1) &&
                (start < slice.m_MinIndex || slice.m_MaxIndex < start || slice.m_MaxIndex < start + length - 1))
            {
                throw new ArgumentException("Slice may not be used on a restricted range slice", nameof(slice));
            }

            this.m_MinIndex = 0;
            this.m_MaxIndex = length - 1;
            this.m_Safety   = slice.m_Safety;
            #endif
            this.m_Stride = slice.m_Stride;
            this.m_Buffer = slice.m_Buffer + this.m_Stride * start;
            this.m_Length = length;
        }
示例#2
0
        public unsafe void CopyFrom(NativeSliceBurst <T> slice)
        {
            if (this.Length != slice.Length)
            {
                throw new ArgumentException(string.Format("slice.Length ({0}) does not match the Length of this instance ({1}).", (object)slice.Length, (object)this.Length),
                                            nameof(slice));
            }

            UnsafeUtility.MemCpyStride(this.GetUnsafePtr(), this.Stride, slice.GetUnsafeReadOnlyPtr(), slice.Stride, UnsafeUtility.SizeOf <T>(), this.m_Length);
        }
示例#3
0
 public Enumerator(ref NativeSliceBurst <T> array)
 {
     this.m_Array = array;
     this.m_Index = -1;
 }
示例#4
0
 public unsafe bool Equals(NativeSliceBurst <T> other)
 {
     return(this.m_Buffer == other.m_Buffer && this.m_Stride == other.m_Stride && this.m_Length == other.m_Length);
 }
示例#5
0
 public NativeSliceBurst(NativeSliceBurst <T> slice, int start) : this(slice, start, slice.Length - start)
 {
 }