Ejemplo n.º 1
0
 public static ulong[] getReverse(this SubArray <ulong> array)
 {
     if (array.Length == 0)
     {
         return(EmptyArray <ulong> .Array);
     }
     return(FixedArray.GetReverse(array.Array, array.Start, array.Length));
 }
Ejemplo n.º 2
0
 public static SubArray <ulong> reverse(this SubArray <ulong> array)
 {
     if (array.Length > 1)
     {
         FixedArray.Reverse(array.Array, array.Start, array.Length);
     }
     return(array);
 }
Ejemplo n.º 3
0
 public static LeftArray <ulong> reverse(this LeftArray <ulong> array)
 {
     if (array.Length > 1)
     {
         FixedArray.Reverse(array.Array, 0, array.Length);
     }
     return(array);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取第一个匹配值
        /// </summary>
        /// <param name="array">数组数据</param>
        /// <param name="isValue">数据匹配器</param>
        /// <param name="index">起始位置</param>
        /// <returns>第一个匹配值,失败为default(ulong)</returns>
        public static ulong firstOrDefault(this SubArray <ulong> array, Func <ulong, bool> isValue, int index)
        {
            if ((uint)index < (uint)array.Length)
            {
                fixed(ulong *valueFixed = array.GetFixedBuffer())
                {
                    ulong *valueIndex = FixedArray.IndexOf(valueFixed + array.Start + index, array.Length - index, isValue);

                    if (valueIndex != null)
                    {
                        return(*valueIndex);
                    }
                }
            }
            return(default(ulong));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取匹配数据位置
        /// </summary>
        /// <param name="array">数据数组</param>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配位置,失败为-1</returns>
        public static int indexOf(this SubArray <ulong> array, Func <ulong, bool> isValue)
        {
            if (array.Length != 0)
            {
                fixed(ulong *valueFixed = array.GetFixedBuffer())
                {
                    ulong *start = valueFixed + array.Start, index = FixedArray.IndexOf(start, array.Length, isValue);

                    if (index != null)
                    {
                        return((int)(index - valueFixed));
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 替换数据
        /// </summary>
        /// <param name="array">数组数据</param>
        /// <param name="value">新值</param>
        /// <param name="isValue">数据匹配器</param>
        public static SubArray <ulong> replaceFirst(this SubArray <ulong> array, ulong value, Func <ulong, bool> isValue)
        {
            if (array.Length != 0)
            {
                fixed(ulong *valueFixed = array.GetFixedBuffer())
                {
                    ulong *valueIndex = FixedArray.IndexOf(valueFixed + array.Start, array.Length, isValue);

                    if (valueIndex != null)
                    {
                        *valueIndex = value;
                    }
                }
            }
            return(array);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取匹配数据位置
        /// </summary>
        /// <param name="array">数组数据</param>
        /// <param name="value">匹配数据</param>
        /// <returns>匹配位置,失败为-1</returns>
        public static int indexOf(this LeftArray <ulong> array, ulong value)
        {
            if (array.Length != 0)
            {
                fixed(ulong *valueFixed = array.GetFixedBuffer())
                {
                    ulong *index = FixedArray.IndexOf(valueFixed, array.Length, value);

                    if (index != null)
                    {
                        return((int)(index - valueFixed));
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取匹配数组
        /// </summary>
        /// <param name="array">数组数据</param>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配数组</returns>
        public static ulong[] getFindArray(this SubArray <ulong> array, Func <ulong, bool> isValue)
        {
            if (array.Length == 0)
            {
                return(EmptyArray <ulong> .Array);
            }
            int length = ((array.Length + 63) >> 6) << 3;

            AutoCSer.Memory.UnmanagedPool pool = AutoCSer.Memory.UnmanagedPool.GetPool(length);
            AutoCSer.Memory.Pointer       data = pool.GetMinSize(length);
            try
            {
                AutoCSer.Memory.Common.Clear(data.ULong, length >> 3);
                return(FixedArray.GetFindArray(array.Array, array.Start, array.Length, isValue, new MemoryMap(data.Data)));
            }
            finally { pool.Push(ref data); }
        }
Ejemplo n.º 9
0
 public static LeftArray <ulong> getFind(this SubArray <ulong> array, Func <ulong, bool> isValue)
 {
     return(array.Length == 0 ? new LeftArray <ulong>(0) : FixedArray.GetFind(array.Array, array.Start, array.Length, isValue));
 }