/// <summary> /// 范围排序 /// </summary> /// <param name="array">待排序数组</param> /// <param name="startIndex">起始位置</param> /// <param name="count">排序范围数据数量</param> /// <param name="skipCount">跳过数据数量</param> /// <param name="getCount">排序数据数量</param> /// <returns>排序后的新数据</returns> internal static SubArray </*Type[0]*/ ulong /*Type[0]*/> UnsafeGetRangeSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] array, int startIndex, int count, int skipCount, int getCount) { if (getCount == 0) { return(default(SubArray </*Type[0]*/ ulong /*Type[0]*/>)); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[count]; Buffer.BlockCopy(array, startIndex * sizeof(/*Type[0]*/ ulong /*Type[0]*/), newValues, 0, count * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *start = newValueFixed + skipCount; new /*Type[1]*/ ULongRangeSorter/*Type[1]*//*Compare[0]*//*Compare[0]*/ { SkipCount = start, GetEndIndex = start + getCount - 1 }.Sort(newValueFixed, newValueFixed + count - 1); } return(new SubArray </*Type[0]*/ ulong /*Type[0]*/> { Array = newValues, Start = skipCount, Length = getCount }); }
/// <summary> /// 排序取Top N /// </summary> /// <param name="values">待排序数组</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的数据</returns> public unsafe static list </*Type[0]*/ ulong /*Type[0]*/> GetTop/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int count) { if (values == null) { return(null); } if (count > 0) { if (count < values.Length) { if (count <= values.Length >> 1) { return(getTop/*Compare[0]*//*Compare[0]*/ (values, count)); } else { return(getRemoveTop/*Compare[0]*//*Compare[0]*/ (values, count)); } } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Array.Copy(values, 0, newValues, 0, values.Length); return(new list </*Type[0]*/ ulong /*Type[0]*/>(newValues, true)); } return(null); }
/// <summary> /// 范围排序 /// </summary> /// <param name="values">待排序数组</param> /// <param name="startIndex">起始位置</param> /// <param name="count">排序范围数据数量</param> /// <param name="skipCount">跳过数据数量</param> /// <param name="getCount">排序数据数量</param> /// <returns>排序后的新数据</returns> public unsafe static collection </*Type[0]*/ ulong /*Type[0]*/> GetRangeSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int startIndex, int count, int skipCount, int getCount) { array.range range = new array.range(values.length(), startIndex, count); if ((count = range.GetCount) != 0) { array.range getRange = new array.range(count, skipCount, getCount); if ((getCount = getRange.GetCount) != 0) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[count]; Buffer.BlockCopy(values, range.SkipCount * sizeof(/*Type[0]*/ ulong /*Type[0]*/), newValues, 0, count * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = values) { new /*Type[1]*/ ulongRangeSorter/*Type[1]*//*Compare[0]*//*Compare[0]*/ { SkipCount = newValueFixed + getRange.SkipCount, GetEndIndex = newValueFixed + getRange.SkipCount + getCount - 1 }.Sort(newValueFixed, newValueFixed + count - 1); } return(new collection </*Type[0]*/ ulong /*Type[0]*/>(newValues, getRange.SkipCount, getCount, true)); } } return(null); }
/// <summary> /// 排序取Top N /// </summary> /// <param name="values">待排序数组</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的数据</returns> public unsafe static subArray </*Type[0]*/ ulong /*Type[0]*/> GetTop/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int count) { if (values == null) { return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>)); } if (count > 0) { if (count < values.Length) { if (count <= values.Length >> 1) { return(getTop/*Compare[0]*//*Compare[0]*/ (values, count)); } values = getRemoveTop/*Compare[0]*//*Compare[0]*/ (values, count); } else { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Array.Copy(values, 0, newValues, 0, values.Length); values = newValues; } return(subArray </*Type[0]*/ ulong /*Type[0]*/> .Unsafe(values, 0, values.Length)); } return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>)); }
/// <summary> /// 查找符合条件的记录集合 /// </summary> /// <param name="values">值集合</param> /// <param name="isValue">判断记录是否符合条件的委托</param> /// <returns>符合条件的记录集合</returns> public unsafe static list </*Type[0]*/ ulong /*Type[0]*/> getFind (this System.Collections.ICollection values, func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue) { if (values != null) { if (isValue == null) { log.Default.Throw(log.exceptionType.Null); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (/*Type[0]*/ ulong /*Type[0]*/ value in values) { if (isValue(value)) { *write++ = value; } } return(new list </*Type[0]*/ ulong /*Type[0]*/>(newValues, 0, (int)(write - newValueFixed), true)); } } return(null); }
/// <summary> /// 根据集合内容返回数组 /// </summary> /// <typeparam name="valueType">枚举值类型</typeparam> /// <param name="values">值集合</param> /// <param name="getValue">获取数组值的委托</param> /// <returns>数组</returns> public unsafe static /*Type[0]*/ ulong /*Type[0]*/[] getArray <valueType> (this System.Collections.Generic.ICollection <valueType> values, func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getValue) { if (values.count() != 0) { if (getValue == null) { log.Default.Throw(log.exceptionType.Null); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (valueType value in values) { *write++ = getValue(value); } } return(newValues); } return(nullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); }
/// <summary> /// 求交集 /// </summary> /// <param name="left">左侧数据</param> /// <param name="right">右侧数据</param> /// <returns>数据交集</returns> public unsafe static subArray </*Type[0]*/ ulong /*Type[0]*/> intersect(this /*Type[0]*/ ulong /*Type[0]*/[] left, /*Type[0]*/ ulong /*Type[0]*/[] right) { int leftLength = left.length(), rightLength = right.length(); if (leftLength != 0 && rightLength != 0) { /*Type[0]*/ ulong /*Type[0]*/[] min = leftLength <= rightLength ? left : right, values = new /*Type[0]*/ ulong /*Type[0]*/[min.Length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *valueFixed = values) { /*Type[0]*/ ulong /*Type[0]*/ *write = valueFixed; staticHashSet </*Type[0]*/ ulong /*Type[0]*/> hash = new staticHashSet </*Type[0]*/ ulong /*Type[0]*/>(min); foreach (/*Type[0]*/ ulong /*Type[0]*/ value in leftLength <= rightLength ? right : left) { if (hash.Contains(value)) { *write++ = value; } } return(subArray </*Type[0]*/ ulong /*Type[0]*/> .Unsafe(values, 0, (int)(write - valueFixed))); } } return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>)); }
/// <summary> /// 排序取Top N /// </summary> /// <param name="values">待排序数组</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的数据</returns> public static LeftArray </*Type[0]*/ ulong /*Type[0]*/> GetTop/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int count) { if (values == null || count <= 0) { return(default(LeftArray </*Type[0]*/ ulong /*Type[0]*/>)); } if (count < values.Length) { if (count <= values.Length >> 1) { return(getTop/*Compare[0]*//*Compare[0]*/ (values, count)); } values = getRemoveTop/*Compare[0]*//*Compare[0]*/ (values, count); } else { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Array.Copy(values, 0, newValues, 0, values.Length); values = newValues; } return(new LeftArray </*Type[0]*/ ulong /*Type[0]*/> { Array = values, Length = values.Length }); }
/// <summary> /// 查找符合条件的记录集合 /// </summary> /// <param name="values">值集合</param> /// <param name="isValue">判断记录是否符合条件的委托</param> /// <returns>符合条件的记录集合</returns> public static LeftArray </*Type[0]*/ ulong /*Type[0]*/> getFind(this System.Collections.Generic.ICollection </*Type[0]*/ ulong /*Type[0]*/> values, Func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue) { if (values.count() == 0) { return(default(LeftArray </*Type[0]*/ ulong /*Type[0]*/>)); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (/*Type[0]*/ ulong /*Type[0]*/ value in values) { if (isValue(value)) { *write++ = value; } } return(new LeftArray </*Type[0]*/ ulong /*Type[0]*/> { Array = newValues, Length = (int)(write - newValueFixed) }); } }
/// <summary> /// 查找符合条件的记录集合 /// </summary> /// <param name="values">值集合</param> /// <param name="isValue">判断记录是否符合条件的委托</param> /// <returns>符合条件的记录集合</returns> public unsafe static subArray </*Type[0]*/ ulong /*Type[0]*/> getFind (this System.Collections.ICollection values, Func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue) { if (values != null) { if (isValue == null) { log.Error.Throw(log.exceptionType.Null); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (/*Type[0]*/ ulong /*Type[0]*/ value in values) { if (isValue(value)) { *write++ = value; } } return(subArray </*Type[0]*/ ulong /*Type[0]*/> .Unsafe(newValues, 0, (int)(write - newValueFixed))); } } return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>)); }
/// <summary> /// 排序去除Top N /// </summary> /// <param name="values">待排序数组</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的数据</returns> private static /*Type[0]*/ ulong /*Type[0]*/[] getRemoveTop/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int count) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[count]; count = values.Length - count; uint sqrtMod; int length = Math.Min(Math.Max(count << 2, count + (int)AutoCSer.Extension.Number.sqrt((uint)values.Length, out sqrtMod)), values.Length); /*Type[0]*/ ulong /*Type[0]*/[] removeValues = new /*Type[0]*/ ulong /*Type[0]*/[length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, removeFixed = removeValues, valueFixed = values) { int copyCount = length - count, copyLength = copyCount * sizeof(/*Type[0]*/ ulong /*Type[0]*/); /*Type[0]*/ ulong /*Type[0]*/ *readIndex = valueFixed + values.Length - length, removeStart = removeFixed + copyCount; Buffer.BlockCopy(values, (int)((byte *)readIndex - (byte *)valueFixed), removeValues, 0, length * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); //unsafer.memory.Copy(readIndex, removeFixed, length * sizeof(/*Type[0]*/ulong/*Type[0]*/)); /*Type[0]*/ ulong /*Type[0]*/ *removeEnd = removeFixed + --length, removeIndex = removeStart, writeIndex = newValueFixed + copyCount; FixedArrayQuickRangeSort./*Type[1]*/ ULongRangeSorter /*Type[1]*//*Compare[0]*//*Compare[0]*/ sort = new FixedArrayQuickRangeSort./*Type[1]*/ ULongRangeSorter /*Type[1]*//*Compare[0]*//*Compare[0]*/ { SkipCount = removeStart, GetEndIndex = removeStart }; sort.Sort(removeFixed, removeEnd); Buffer.BlockCopy(removeValues, 0, newValues, 0, copyLength); //unsafer.memory.Copy(removeFixed, newValueFixed, copyLength); for (/*Type[0]*/ ulong /*Type[0]*/ maxValue = *removeStart; readIndex != valueFixed;) { if (*--readIndex /*Compare[2]*/ <= /*Compare[2]*/ maxValue) { *writeIndex++ = *readIndex; } else { *--removeIndex = *readIndex; if (removeIndex == removeFixed) { sort.Sort(removeFixed, removeEnd); removeIndex = removeStart; maxValue = *removeStart; Buffer.BlockCopy(removeValues, 0, newValues, (int)((byte *)writeIndex - (byte *)newValueFixed), copyLength); //unsafer.memory.Copy(removeFixed, writeIndex, copyLength); writeIndex += copyCount; } } } if (removeIndex != removeStart) { sort.Sort(removeIndex, removeEnd); Buffer.BlockCopy(removeValues, (int)((byte *)removeIndex - (byte *)removeFixed), newValues, (int)((byte *)writeIndex - (byte *)newValueFixed), (int)((byte *)removeStart - (byte *)removeIndex)); //unsafer.memory.Copy(removeIndex, writeIndex, (int)(removeStart - removeIndex) * sizeof(/*Type[0]*/ulong/*Type[0]*/)); } } return(newValues); }
/// <summary> /// 逆转数组 /// </summary> /// <param name="array">数组数据</param> /// <param name="index">起始位置</param> /// <param name="length">翻转数据数量</param> /// <returns>翻转后的新数组</returns> internal static /*Type[0]*/ ulong /*Type[0]*/[] GetReverse(/*Type[0]*/ ulong /*Type[0]*/[] array, int index, int length) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *valueFixed = array, newValueFixed = newValues) { for (/*Type[0]*/ ulong /*Type[0]*/ *start = valueFixed + index, end = start + length, wirte = newValueFixed + length; start != end; *--wirte = *start++) { ; } } return(newValues); }
/// <summary> /// 排序取Top N /// </summary> /// <param name="values">待排序数组</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的数据</returns> private unsafe static subArray </*Type[0]*/ ulong /*Type[0]*/> getTop/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int count) { uint sqrtMod; int length = Math.Min(Math.Max(count << 2, count + (int)number.sqrt((uint)values.Length, out sqrtMod)), values.Length); /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = values) { /*Type[0]*/ ulong /*Type[0]*/ *readIndex = valueFixed + values.Length - length; Buffer.BlockCopy(values, (int)((byte *)readIndex - (byte *)valueFixed), newValues, 0, length * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); //unsafer.memory.Copy(readIndex, newValueFixed, length * sizeof(/*Type[0]*/ulong/*Type[0]*/)); /*Type[0]*/ ulong /*Type[0]*/ *writeStat = newValueFixed + count, writeEnd = newValueFixed + --length, writeIndex = writeStat; /*Type[1]*/ ulongRangeSorter /*Type[1]*//*Compare[0]*//*Compare[0]*/ sort = new /*Type[1]*/ ulongRangeSorter/*Type[1]*//*Compare[0]*//*Compare[0]*/ { SkipCount = writeStat - 1, GetEndIndex = writeStat - 1 }; sort.Sort(newValueFixed, writeEnd); for (/*Type[0]*/ ulong /*Type[0]*/ maxValue = *sort.SkipCount; readIndex != valueFixed;) { if (*--readIndex /*Compare[1]*/ < /*Compare[1]*/ maxValue) { *writeIndex = *readIndex; if (writeIndex == writeEnd) { sort.Sort(newValueFixed, writeEnd); writeIndex = writeStat; maxValue = *sort.SkipCount; } else { ++writeIndex; } } } if (writeIndex != writeStat) { sort.Sort(newValueFixed, --writeIndex); } } return(subArray </*Type[0]*/ ulong /*Type[0]*/> .Unsafe(newValues, 0, count)); }
/// <summary> /// 数组排序 /// </summary> /// <param name="values">待排序数组</param> /// <returns>排序后的新数组</returns> public static /*Type[0]*/ ulong /*Type[0]*/[] GetSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values) { if (values.Length == 0) { return(values); } /*Type[0]*/ ulong /*Type[0]*/[] newValue = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Buffer.BlockCopy(values, 0, newValue, 0, values.Length * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValue, valueFixed = values) sort/*Compare[0]*//*Compare[0]*/ (newValueFixed, newValueFixed + values.Length - 1); return(newValue); }
/// <summary> /// 数组排序 /// </summary> /// <param name="values">待排序数组</param> /// <returns>排序后的新数组</returns> public unsafe static /*Type[0]*/ ulong /*Type[0]*/[] GetSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values) { if (values.length() != 0) { /*Type[0]*/ ulong /*Type[0]*/[] newValue = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Buffer.BlockCopy(values, 0, newValue, 0, values.Length * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValue, valueFixed = values) { sort/*Compare[0]*//*Compare[0]*/ (newValueFixed, newValueFixed + values.Length - 1); } return(newValue); } return(nullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); }
/// <summary> /// 数组排序 /// </summary> /// <param name="values">待排序数组</param> /// <param name="startIndex">起始位置</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的新数组</returns> public static /*Type[0]*/ ulong /*Type[0]*/[] GetSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int startIndex, int count) { if (count == 0) { return(NullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[count]; Buffer.BlockCopy(values, startIndex * sizeof(/*Type[0]*/ ulong /*Type[0]*/), newValues, 0, count * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = values) { if (--count > 0) { sort/*Compare[0]*//*Compare[0]*/ (newValueFixed, newValueFixed + count); } } return(newValues); }
/// <summary> /// 数组排序 /// </summary> /// <param name="values">待排序数组</param> /// <param name="startIndex">起始位置</param> /// <param name="count">排序数据数量</param> /// <returns>排序后的新数组</returns> public unsafe static /*Type[0]*/ ulong /*Type[0]*/[] GetSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int startIndex, int count) { array.range range = new array.range(values.length(), startIndex, count); if ((count = range.GetCount) != 0) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[count]; Buffer.BlockCopy(values, range.SkipCount * sizeof(/*Type[0]*/ ulong /*Type[0]*/), newValues, 0, count * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = values) { if (--count > 0) { sort/*Compare[0]*//*Compare[0]*/ (newValueFixed, newValueFixed + count); } } return(newValues); } return(nullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); }
/// <summary> /// 根据集合内容返回数组 /// </summary> /// <typeparam name="valueType">枚举值类型</typeparam> /// <param name="values">值集合</param> /// <param name="getValue">获取数组值的委托</param> /// <returns>数组</returns> public static /*Type[0]*/ ulong /*Type[0]*/[] getArray <valueType>(this System.Collections.Generic.ICollection <valueType> values, Func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getValue) { if (values.count() == 0) { return(NullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (valueType value in values) { *write++ = getValue(value); } } return(newValues); }
/// <summary> /// 数据转换 /// </summary> /// <typeparam name="valueType">数组类型</typeparam> /// <param name="array">数据数组</param> /// <param name="getValue">数据获取器</param> /// <returns>目标数组</returns> public static /*Type[0]*/ ulong /*Type[0]*/[] getArray <valueType>(this valueType[] array, Func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getValue) { if (array.isEmpty()) { return(NullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); } /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[array.Length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *writeValue = newValueFixed; foreach (valueType value in array) { *writeValue++ = getValue(value); } } return(newValues); }
/// <summary> /// 获取匹配集合 /// </summary> /// <param name="array">数组数据</param> /// <param name="index">起始位置</param> /// <param name="length">翻转数据数量</param> /// <param name="isValue">数据匹配器</param> /// <returns>匹配集合</returns> internal static LeftArray </*Type[0]*/ ulong /*Type[0]*/> GetFind(this /*Type[0]*/ ulong /*Type[0]*/[] array, int index, int length, Func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[length < sizeof(int) ? sizeof(int) : length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = array) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; for (/*Type[0]*/ ulong /*Type[0]*/ *start = valueFixed + index, end = valueFixed + length; start != end; ++start) { if (isValue(*start)) { *write++ = *start; } } return(new LeftArray </*Type[0]*/ ulong /*Type[0]*/> { Array = newValues, Length = (int)(write - newValueFixed) }); } }
/// <summary> /// 根据集合内容返回数组 /// </summary> /// <param name="values">值集合</param> /// <returns>数组</returns> public unsafe static /*Type[0]*/ ulong /*Type[0]*/[] getArray (this System.Collections.Generic.ICollection </*Type[0]*/ ulong /*Type[0]*/> values) { if (values.count() != 0) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Count]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; foreach (/*Type[0]*/ ulong /*Type[0]*/ value in values) { *write++ = value; } } return(newValues); } return(nullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); }
/// <summary> /// 范围排序 /// </summary> /// <param name="values">待排序数组</param> /// <param name="skipCount">跳过数据数量</param> /// <param name="getCount">排序数据数量</param> /// <returns>排序后的新数据</returns> public unsafe static subArray </*Type[0]*/ ulong /*Type[0]*/> GetRangeSort/*Compare[0]*//*Compare[0]*/ (/*Type[0]*/ ulong /*Type[0]*/[] values, int skipCount, int getCount) { array.range range = new array.range(values.length(), skipCount, getCount); if ((getCount = range.GetCount) != 0) { /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[values.Length]; Buffer.BlockCopy(values, 0, newValues, 0, values.Length * sizeof(/*Type[0]*/ ulong /*Type[0]*/)); fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues, valueFixed = values) { new /*Type[1]*/ ulongRangeSorter/*Type[1]*//*Compare[0]*//*Compare[0]*/ { SkipCount = newValueFixed + range.SkipCount, GetEndIndex = newValueFixed + range.EndIndex - 1 }.Sort(newValueFixed, newValueFixed + values.Length - 1); } return(subArray </*Type[0]*/ ulong /*Type[0]*/> .Unsafe(newValues, range.SkipCount, getCount)); } return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>)); }
/// <summary> /// 数组类型转换 /// </summary> /// <typeparam name="valueType">数据类型</typeparam> /// <param name="subArray">数据数组</param> /// <param name="getValue">数据获取器</param> /// <returns>目标数组</returns> public static /*Type[0]*/ ulong /*Type[0]*/[] getArray <valueType>(this SubArray <valueType> subArray, Func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getValue) { if (subArray.Length == 0) { return(NullValue </*Type[0]*/ ulong /*Type[0]*/> .Array); } valueType[] array = subArray.Array; /*Type[0]*/ ulong /*Type[0]*/[] newValues = new /*Type[0]*/ ulong /*Type[0]*/[subArray.Length]; fixed(/*Type[0]*/ ulong /*Type[0]*/ *newValueFixed = newValues) { /*Type[0]*/ ulong /*Type[0]*/ *write = newValueFixed; int index = subArray.Start, endIndex = index + subArray.Length; do { *write++ = getValue(array[index++]); }while (index != endIndex); } return(newValues); }