/// <summary> /// 添加方法索引信息 /// </summary> /// <param name="method">方法索引信息</param> public void Add(AjaxMethod method) { MethodParameter[] inputParameters = method.MethodParameters, outputParameters = method.Method.OutputParameters; MethodParameterTypeNames inputParameterTypeNames = new MethodParameterTypeNames(inputParameters, false, method.Attribute.IsInputSerializeBox); MethodParameterTypeNames outputParameterTypeNames = method.MethodIsReturn ? new MethodParameterTypeNames(outputParameters, method.MethodReturnType, false, method.Attribute.IsOutputSerializeBox) : new MethodParameterTypeNames(outputParameters, false, method.Attribute.IsOutputSerializeBox); MethodParameterTypeNames historyInputJsonParameterIndex = default(MethodParameterTypeNames), historyOutputJsonParameterIndex = default(MethodParameterTypeNames); if (inputParameterTypeNames.IsParameter) { if (!ParameterIndexs.TryGetValue(ref inputParameterTypeNames, out historyInputJsonParameterIndex)) { inputParameterTypeNames.Copy(++ParameterIndex); ParameterIndexs.Set(ref inputParameterTypeNames, historyInputJsonParameterIndex = inputParameterTypeNames); } method.InputParameterIndex = historyInputJsonParameterIndex.Index; } if (outputParameterTypeNames.IsParameter) { if (!ParameterIndexs.TryGetValue(ref outputParameterTypeNames, out historyOutputJsonParameterIndex)) { outputParameterTypeNames.Copy(++ParameterIndex); ParameterIndexs.Set(ref outputParameterTypeNames, historyOutputJsonParameterIndex = outputParameterTypeNames); } method.OutputParameterIndex = historyOutputJsonParameterIndex.Index; } method.InputParameters = MethodParameterPair.Get(inputParameters, historyInputJsonParameterIndex); method.OutputParameters = MethodParameterPair.Get(outputParameters, historyOutputJsonParameterIndex); MethodParameterPair.SetInputParameter(method.OutputParameters, method.InputParameters); }
/// <summary> /// 添加新的数据 /// </summary> /// <param name="key">数据标识</param> /// <param name="values">分词结果</param> public void Add(ref keyType key, ReusableDictionary <HashString, ResultIndexLeftArray> values) { WordCounterIndex counterIndex; ResultIndexArray resultIndex = default(ResultIndexArray); foreach (KeyValue <HashString, ResultIndexLeftArray> result in values.KeyValues) { if (!results.TryGetValue(result.Key, out counterIndex)) { counterIndex.Index = counterPool.Get(out counterIndex.Array); results.Set(result.Key, counterIndex); counterIndex.CreateResult(); } if ((flags & SearchFlags.ResultIndexs) == 0) { resultIndex.Set(EmptyArray <int> .Array, result.Value.TextLength); counterIndex.Add(key, result.Value.WordType, ref resultIndex); ++WordCount; } else { resultIndex.Set(result.Value.Indexs.GetArray(), result.Value.TextLength); counterIndex.Add(key, result.Value.WordType, ref resultIndex); WordCount += result.Value.Indexs.Length; } } ++Version; }
/// <summary> /// 进入对象节点 /// </summary> /// <typeparam name="valueType">对象类型</typeparam> /// <param name="value">数据对象</param> /// <returns>是否继续处理对象</returns> private bool pushArray <valueType>(valueType value) { if (checkLoopDepth == 0) { if (forefatherCount != 0) { int count = forefatherCount; object objectValue = value; foreach (object arrayValue in forefather) { if (arrayValue == objectValue) { CharStream.WriteJsonObject(); return(false); } if (--count == 0) { break; } } } if (forefatherCount == forefather.Length) { forefather = forefather.copyNew(forefatherCount << 1); } forefather[forefatherCount++] = value; } else { if (--checkLoopDepth == 0) { throw new OverflowException(); } if (isLoopObject) { string index; if (objectIndexs.TryGetValue(new ObjectReference { Value = value }, out index)) { CharStream.PrepLength(Config.GetLoopObject.Length + index.Length + (5 + 3)); CharStream.UnsafeSimpleWrite(Config.GetLoopObject); CharStream.UnsafeWrite('('); CharStream.UnsafeSimpleWrite(index); CharStream.UnsafeSimpleWrite(",[])"); return(false); } objectIndexs.Set(new ObjectReference { Value = value }, index = objectIndexs.Count.toString()); CharStream.PrepLength(Config.SetLoopObject.Length + index.Length + (2 + 2)); CharStream.UnsafeSimpleWrite(Config.SetLoopObject); CharStream.UnsafeWrite('('); CharStream.UnsafeSimpleWrite(index); CharStream.UnsafeWrite(','); } } return(true); }
/// <summary> /// 添加方法索引信息 /// </summary> /// <param name="method">方法索引信息</param> public void Add(CallMethod method) { MethodParameter[] parameters = method.MethodParameters; MethodParameterTypeNames parameterTypeNames = new MethodParameterTypeNames(parameters, false, false); MethodParameterTypeNames historyJsonParameterIndex = default(MethodParameterTypeNames); if (parameterTypeNames.IsParameter) { if (!ParameterIndexs.TryGetValue(ref parameterTypeNames, out historyJsonParameterIndex)) { parameterTypeNames.Copy(++ParameterIndex); ParameterIndexs.Set(ref parameterTypeNames, historyJsonParameterIndex = parameterTypeNames); } method.ParameterIndex = historyJsonParameterIndex.Index; } //method.Parameters = MethodParameterPair.Get(parameters, historyJsonParameterIndex); }
/// <summary> /// 下一个函数处理 /// </summary> /// <param name="methodIndex"></param> private void next(TcpMethod methodIndex) { AutoCSer.Net.TcpStaticServer.MethodAttribute attribute = methodIndex.Attribute; Server server = defaultServer; ServerType serverType = defaultType; string serviceName = attribute.GetServerName; if (serviceName == null) { serviceName = Attribute.ServerName; } if (serviceName != defaultServerName) { if (serviceName == null) { serverType = null; } else { HashString nameKey = serviceName; if (!servers.TryGetValue(nameKey, out server)) { servers.Add(nameKey, server = new Server()); server.Attribute.Name = serviceName; } if (!serverTypes.TryGetValue(ref nameKey, out serverType)) { server.Types.Add(serverType = new ServerType { Type = Type }); serverTypes.Set(ref nameKey, serverType); } } } if (serverType != null) { server.IsMethod = true; methodIndex.ServiceAttribute = server.Attribute; //methodIndex.MethodIndex = server.MethodIndex++; //methodIndex.ParameterIndex = parameterIndex++; serverType.Methods.Add(methodIndex); } }
/// <summary> /// 添加图片 /// </summary> /// <param name="bitmap">位图</param> /// <param name="leftOffset">X方向偏移量</param> /// <param name="topOffset">Y方向偏移量</param> /// <param name="width">图象宽度</param> /// <param name="height">图象高度</param> /// <param name="bitmapLeftOffset">位图剪切X方向偏移量</param> /// <param name="bitmapTopOffset">位图剪切Y方向偏移量</param> /// <param name="isInterlace">图象数据是否连续方式排列,否则使用顺序排列</param> /// <param name="maxPixel">最大色彩深度</param> /// <returns>图片是否添加成功</returns> internal unsafe bool addImage(BitmapData bitmap, int bitmapLeftOffset, int bitmapTopOffset , int leftOffset, int topOffset, int width, int height, bool isInterlace, byte maxPixel) { if (fileBuffer == null) { return(false); fixed(Color *colorFixed = colors) fixed(int *colorCountFixed = colorCounts) { byte * bitmapFixed = (byte *)bitmap.Scan0, currentBitmap = bitmapFixed + bitmap.Stride * (bitmapTopOffset - 1) + (bitmapLeftOffset + width) * 3; Color *currentColor = colorFixed; int bitMapSpace = bitmap.Stride - (width << 1) - width; colorIndexs.Empty(); for (int colorIndex, row = height; row != 0; --row) { currentBitmap += bitMapSpace; for (int col = width; col != 0; --col) { Color color = new Color { Green = *currentBitmap++, Blue = *currentBitmap++, Red = *currentBitmap++ }; if (colorIndexs.TryGetValue(color, out colorIndex)) { ++colorCountFixed[colorIndex]; } else { colorIndexs.Set(color, colorIndex = (int)(currentColor - colorFixed)); colorCountFixed[colorIndex] = 1; } *currentColor++ = color; } } int pixel = ((uint)colorIndexs.Count).bits() - 1; if ((1 << pixel) != colorIndexs.Count) { ++pixel; } if (pixel > maxPixel) { pixel = maxPixel; } else if (pixel < 2) { pixel = 2; } int maxColorCount = 1 << pixel; fixed(byte *bufferFixed = fileBuffer) { byte *currentBuffer = bufferFixed + bufferIndex; *currentBuffer = 0x2c; *(short *)(currentBuffer + 1) = (short)leftOffset; *(short *)(currentBuffer + 3) = (short)topOffset; *(short *)(currentBuffer + 5) = (short)width; *(short *)(currentBuffer + 7) = (short)height; *(currentBuffer + 9) = (byte)(0x80 + (isInterlace ? 0x40 : 0) + (pixel - 1)); if (!checkBuffer(bufferFixed, 10)) { return(false); } } if (colorIndexs.Count <= maxColorCount) { fixed(byte *bufferFixed = fileBuffer) { int *currentColorCount = colorCountFixed; foreach (Color colorKey in colorIndexs.Keys) { *currentColorCount++ = colorKey.Value; } Color color = new Color(); int currentColorIndex = 0; byte *currentBuffer = bufferFixed + bufferIndex; while (currentColorCount != colorCountFixed) { color.Value = *--currentColorCount; *currentBuffer++ = color.Red; *currentBuffer++ = color.Blue; *currentBuffer++ = color.Green; colorIndexs.Set(color, currentColorIndex++); } *(bufferFixed + bufferIndex + (maxColorCount << 1) + maxColorCount) = (byte)pixel; if (!checkBuffer(bufferFixed, (maxColorCount << 1) + maxColorCount + 1)) { return(false); } } } else { int indexCount = colorIndexs.Count; UnmanagedPool pool = UnmanagedPool.GetDefaultPool(indexCount * sizeof(IntSortIndex)); Pointer.Size sizeBuffer = pool.GetSize(indexCount * (sizeof(IntSortIndex) + sizeof(int))); int * buffer = sizeBuffer.Int; try { IntSortIndex *indexFixed = (IntSortIndex *)(buffer + indexCount), currentSortIndex = indexFixed; foreach (KeyValue <Color, int> colorIndex in colorIndexs.KeyValues) { int color0 = colorIndex.Key.Value; int color3 = ((color0 >> 3) & 0x111111) * 0x1020400; int color2 = ((color0 >> 2) & 0x111111) * 0x1020400; int color1 = ((color0 >> 1) & 0x111111) * 0x1020400; color0 = (color0 & 0x111111) * 0x1020400; (*currentSortIndex++).Set((color3 & 0x70000000) | ((color2 >> 4) & 0x7000000) | ((color1 >> 8) & 0x700000) | ((color0 >> 12) & 0x70000) | ((color3 >> 12) & 0x7000) | ((color2 >> 16) & 0x700) | ((color1 >> 20) & 0x70) | ((color0 >> 24) & 7), colorIndex.Value); } AutoCSer.Algorithm.FixedArrayQuickSort.sort(indexFixed, indexFixed + indexCount - 1); int *currentSortArray; if (maxColorCount != 2) { currentSortArray = buffer; for (int currentColorCode, lastColorCode = (*--currentSortIndex).Value; currentSortIndex != indexFixed; lastColorCode = currentColorCode) { currentColorCode = (*--currentSortIndex).Value; *currentSortArray++ = lastColorCode - currentColorCode; } currentSortArray = buffer + (maxColorCount >> 1) - 2; new AutoCSer.Algorithm.FixedArrayQuickRangeSort.IntRangeSorterDesc { SkipCount = currentSortArray, GetEndIndex = currentSortArray }.Sort(buffer, buffer + indexCount - 2); int minColorDifference = *currentSortArray, minColorDifferenceCount = 1; while (currentSortArray != buffer) { if (*--currentSortArray == minColorDifference) { ++minColorDifferenceCount; } } currentSortIndex = indexFixed + indexCount; int maxCountIndex = (*--currentSortIndex).Index, maxCount = *(colorCountFixed + maxCountIndex); for (int currentColorCode, lastColorCode = (*currentSortIndex).Value; currentSortIndex != indexFixed; lastColorCode = currentColorCode) { currentColorCode = (*--currentSortIndex).Value; int colorDifference = lastColorCode - currentColorCode; if (colorDifference >= minColorDifference) { if (colorDifference == minColorDifference && --minColorDifferenceCount == 0) { ++minColorDifference; } *(colorCountFixed + maxCountIndex) = int.MaxValue; maxCount = *(colorCountFixed + (maxCountIndex = (*currentSortIndex).Index)); } else { int countIndex = (*currentSortIndex).Index, count = *(colorCountFixed + countIndex); if (count > maxCount) { maxCountIndex = countIndex; maxCount = count; } } } *(colorCountFixed + maxCountIndex) = int.MaxValue; } for (currentSortArray = buffer + indexCount, currentSortIndex = indexFixed; currentSortArray != buffer; *(--currentSortArray) = *(colorCountFixed + (*currentSortIndex++).Index)) { ; } currentSortArray = buffer + maxColorCount - 1; new AutoCSer.Algorithm.FixedArrayQuickRangeSort.IntRangeSorterDesc { SkipCount = currentSortArray, GetEndIndex = currentSortArray }.Sort(buffer, buffer + indexCount - 1); int minColorCount = *currentSortArray, minColorCounts = 1; while (currentSortArray != buffer) { if (*--currentSortArray == minColorCount) { ++minColorCounts; } } fixed(byte *fileBufferFixed = fileBuffer) { byte * currentBuffer = fileBufferFixed + bufferIndex; IntSortIndex *lastSortIndex = indexFixed, endSortIndex = indexFixed + indexCount; while (*(colorCountFixed + (*lastSortIndex).Index) < minColorCount) { colorIndexs.Set(*(colorFixed + (*lastSortIndex++).Index), 0); } if (*(colorCountFixed + (*lastSortIndex).Index) == minColorCount && --minColorCounts == 0) { ++minColorCount; } Color outputColor = *(colorFixed + (*lastSortIndex).Index); *currentBuffer++ = outputColor.Red; *currentBuffer++ = outputColor.Blue; *currentBuffer++ = outputColor.Green; colorIndexs.Set(outputColor, 0); for (--maxColorCount; *(colorCountFixed + (*--endSortIndex).Index) < minColorCount; colorIndexs.Set(*(colorFixed + (*endSortIndex).Index), maxColorCount)) { ; } if (*(colorCountFixed + (*endSortIndex).Index) == minColorCount && --minColorCounts == 0) { ++minColorCount; } colorIndexs.Set(*(colorFixed + (*endSortIndex).Index), maxColorCount++); int currentColorIndex = 0; for (int *lastColorCount = colorCountFixed + (*endSortIndex).Index; lastSortIndex != endSortIndex;) { for (*lastColorCount = 0; *(colorCountFixed + (*++lastSortIndex).Index) >= minColorCount; colorIndexs.Set(outputColor, ++currentColorIndex)) { if (*(colorCountFixed + (*lastSortIndex).Index) == minColorCount && --minColorCounts == 0) { ++minColorCount; } outputColor = *(colorFixed + (*lastSortIndex).Index); *currentBuffer++ = outputColor.Red; *currentBuffer++ = outputColor.Blue; *currentBuffer++ = outputColor.Green; } if (lastSortIndex == endSortIndex) { break; } *lastColorCount = int.MaxValue; IntSortIndex *nextSortIndex = lastSortIndex; while (*(colorCountFixed + (*++nextSortIndex).Index) < minColorCount) { ; } for (int lastColorCode = (*(lastSortIndex - 1)).Value, nextColorCode = (*nextSortIndex).Value; lastSortIndex != nextSortIndex; ++lastSortIndex) { colorIndexs.Set(*(colorFixed + (*lastSortIndex).Index), (*lastSortIndex).Value - lastColorCode <= nextColorCode - (*lastSortIndex).Value ? currentColorIndex : (currentColorIndex + 1)); } if (lastSortIndex != endSortIndex) { if (*(colorCountFixed + (*lastSortIndex).Index) == minColorCount && --minColorCounts == 0) { ++minColorCount; } outputColor = *(colorFixed + (*lastSortIndex).Index); *currentBuffer++ = outputColor.Red; *currentBuffer++ = outputColor.Blue; *currentBuffer++ = outputColor.Green; colorIndexs.Set(outputColor, ++currentColorIndex); } } outputColor = *(colorFixed + (*lastSortIndex).Index); *currentBuffer++ = outputColor.Red; *currentBuffer++ = outputColor.Blue; *currentBuffer++ = outputColor.Green; *currentBuffer = (byte)pixel; if (!checkBuffer(fileBufferFixed, (maxColorCount << 1) + maxColorCount + 1)) { return(false); } } } finally { pool.Push(ref sizeBuffer); } } byte *colorIndexFixed = (byte *)colorCountFixed; if (isInterlace) { Color *colorEnd = colorFixed + width * height; int inputSpace = (width << 3) - width; for (Color *inputColor = colorFixed; inputColor < colorEnd; inputColor += inputSpace) { for (Color *inputEnd = inputColor + width; inputColor != inputEnd; *colorIndexFixed++ = (byte)colorIndexs[*inputColor++]) { ; } } for (Color *inputColor = colorFixed + (width << 2); inputColor < colorEnd; inputColor += inputSpace) { for (Color *inputEnd = inputColor + width; inputColor != inputEnd; *colorIndexFixed++ = (byte)colorIndexs[*inputColor++]) { ; } } inputSpace -= width << 2; for (Color *inputColor = colorFixed + (width << 1); inputColor < colorEnd; inputColor += inputSpace) { for (Color *inputEnd = inputColor + width; inputColor != inputEnd; *colorIndexFixed++ = (byte)colorIndexs[*inputColor++]) { ; } } for (Color *inputColor = colorFixed + width; inputColor < colorEnd; inputColor += width) { for (Color *inputEnd = inputColor + width; inputColor != inputEnd; *colorIndexFixed++ = (byte)colorIndexs[*inputColor++]) { ; } } } else { for (Color *inputColor = colorFixed, inputEnd = colorFixed + width * height; inputColor != inputEnd; *colorIndexFixed++ = (byte)colorIndexs[*inputColor++]) { ; } } return(lzwEncode((byte *)colorCountFixed, colorIndexFixed, pixel)); } }
/// <summary> /// 获取文本分词结果 /// </summary> /// <param name="text"></param> protected void getResult(string text) { result.Empty(); formatLength = text.Length; formatText = AutoCSer.Extension.StringExtension.FastAllocateString(formatLength + 1); fixed(char *textFixed = formatText) { Simplified.FormatNotEmpty(text, textFixed, formatLength); words.Length = matchs.Length = 0; char *start = textFixed, end = textFixed + formatLength; byte type, nextType, wordType; bool isMatchMap = false; if (charTypeData != StringTrieGraph.DefaultCharTypeData.Byte) { StaticStringTrieGraph trieGraph = searcher.trieGraph; int count, index, startIndex; char trieGraphHeadChar = trieGraph.AnyHeadChar; do { if (((type = charTypeData[*start]) & StringTrieGraph.TrieGraphHeadFlag) == 0) { *end = trieGraphHeadChar; do { if ((type & ((byte)WordType.Chinese | (byte)WordType.TrieGraph)) == ((byte)WordType.Chinese | (byte)WordType.TrieGraph)) { addWord((int)(start - textFixed), 1, WordType.Chinese); } if (((nextType = charTypeData[*++start]) & StringTrieGraph.TrieGraphHeadFlag) != 0) { if (start == end) { goto TRIEGRAPHEND; } if ((nextType & (byte)WordType.Chinese) != 0 || (type & nextType & ((byte)WordType.OtherLetter | (byte)WordType.Letter | (byte)WordType.Number | (byte)WordType.Keep)) == 0) { goto TRIEGRAPH; } } type = nextType; }while (true); } TRIEGRAPH: *end = ' '; char *segment = start, segmentEnd = (type & StringTrieGraph.TrieGraphEndFlag) == 0 ? start++ : ++start; while (((type = charTypeData[*start]) & (byte)WordType.TrieGraph) != 0) { ++start; if ((type & StringTrieGraph.TrieGraphEndFlag) != 0) { segmentEnd = start; } } if ((int)(start - segment) == 1) { if ((type & (byte)WordType.Chinese) != 0) { addWord((int)(segment - textFixed), 1, (type & (byte)WordType.TrieGraph) != 0 ? WordType.TrieGraph : WordType.Chinese); } } else { if (segment != segmentEnd) { matchs.Length = 0; trieGraph.LeftRightMatchs(segment, segmentEnd, ref matchs); if ((count = matchs.Length) == 0) { segmentEnd = segment; goto CHINESE; } if (!isMatchMap) { checkMatchMap(); isMatchMap = true; } startIndex = (int)(segment - textFixed); foreach (KeyValue <int, int> value in matchs.Array) { addWord(index = value.Key + startIndex, value.Value, WordType.TrieGraph); matchMap.Set(index, value.Value); if (--count == 0) { break; } } index = (int)(segmentEnd - textFixed); do { if (matchMap.Get(startIndex) == 0 && (charTypeData[textFixed[startIndex]] & (byte)WordType.Chinese) != 0) { addWord(startIndex, 1, WordType.Chinese); } }while (++startIndex != index); } CHINESE: while (segmentEnd != start) { if ((charTypeData[*segmentEnd] & (byte)WordType.Chinese) != 0) { addWord((int)(segmentEnd - textFixed), 1, WordType.Chinese); } ++segmentEnd; } } }while (start != end); TRIEGRAPHEND: start = textFixed; } do { type = charTypeData[*start]; if ((type &= ((byte)WordType.Chinese | (byte)WordType.OtherLetter | (byte)WordType.Letter | (byte)WordType.Number | (byte)WordType.Keep)) == 0) { *end = '0'; do { type = charTypeData[*++start]; if ((type &= ((byte)WordType.Chinese | (byte)WordType.OtherLetter | (byte)WordType.Letter | (byte)WordType.Number | (byte)WordType.Keep)) != 0) { if (start == end) { goto END; } goto OTHER; } }while (true); } OTHER: *end = ' '; if ((type & (byte)WordType.Chinese) != 0) { do { if ((type & (byte)WordType.TrieGraph) == 0) { addWord((int)(start - textFixed), 1, WordType.Chinese); } }while (((type = charTypeData[*++start]) & (byte)WordType.Chinese) != 0); } else { char *segment = start; if ((type & (byte)WordType.OtherLetter) == 0) { char *word = start; wordType = type; for (nextType = charTypeData[*++start]; (nextType &= ((byte)WordType.Letter | (byte)WordType.Number | (byte)WordType.Keep)) != 0; nextType = charTypeData[*++start]) { if (type != nextType) { if (type != (byte)WordType.Keep) { addWord((int)(word - textFixed), (int)(start - word), (WordType)type); } wordType |= nextType; type = nextType; word = start; } } if (word != segment && type != (byte)WordType.Keep) { addWord((int)(word - textFixed), (int)(start - word), (WordType)type); } addWord((int)(segment - textFixed), (int)(start - segment), (WordType)wordType); } else { while ((charTypeData[*++start] & (byte)WordType.OtherLetter) != 0) { ; } addWord((int)(segment - textFixed), (int)(start - segment), WordType.OtherLetter); } } }while (start != end); END: if (words.Length != 0) { int count = words.Length, textLength = text.Length; if ((searcher.flags & SearchFlags.ResultIndexs) == 0) { foreach (KeyValue <SubString, WordType> word in words.Array) { result.Set(word.Key, new ResultIndexLeftArray { WordType = word.Value, TextLength = textLength }); if (--count == 0) { break; } } } else { ResultIndexLeftArray indexs; foreach (KeyValue <SubString, WordType> word in words.Array) { HashString wordKey = word.Key; if (result.TryGetValue(ref wordKey, out indexs)) { indexs.Indexs.Add(word.Key.Start); result.Set(ref wordKey, indexs); } else { indexs.Set(textLength, word.Value); if (indexArrays.Length != 0) { indexs.Indexs.Set(indexArrays.UnsafePopOnly(), 0); } indexs.Indexs.Add(word.Key.Start); result.Set(ref wordKey, indexs); } if (--count == 0) { break; } } foreach (ResultIndexLeftArray indexArray in result.Values) { indexArray.Indexs.Sort(); } } } } }
/// <summary> /// 获取搜索数据标识集合(匹配所有分词结果) /// </summary> /// <param name="text">搜索关键字</param> /// <param name="maxSize">关键字最大字符长度</param> /// <param name="isKey">数据标识过滤</param> /// <returns>数据标识集合</returns> public LeftArray <keyType> SearchAll(string text, int maxSize, Func <keyType, bool> isKey = null) { resultArray.Length = 0; Simplified.Set(text, maxSize); Search(true); switch (queryResult.Count) { case 0: break; case 1: foreach (KeyValuePair <keyType, ResultIndexArray> result in queryResult[0].Value.Dictionary) { if (isKey(result.Key)) { resultArray.Add(result.Key); } } break; default: Dictionary <keyType, ResultIndexArray> resultDictionary = null; foreach (KeyValue <HashString, QueryResult> result in queryResult) { if (resultDictionary == null || result.Value.Dictionary.Count < resultDictionary.Count) { resultDictionary = result.Value.Dictionary; } } resultCountDictionary.Empty(); foreach (keyType key in resultDictionary.Keys) { if (isKey(key)) { resultCountDictionary.Set(key, 0); } } if (resultCountDictionary.Count != 0) { int count = 0, keyCount = resultCountDictionary.Count; foreach (KeyValue <HashString, QueryResult> result in queryResult) { if (!object.ReferenceEquals(result.Value.Dictionary, resultDictionary)) { int nextCount = count + 1, resultCount; keyCount = 0; foreach (keyType key in result.Value.Dictionary.Keys) { if (resultCountDictionary.TryGetValue(key, out resultCount) && resultCount == count) { resultCountDictionary.Set(key, nextCount); ++keyCount; } } if (keyCount == 0) { resultCountDictionary.Empty(); break; } count = nextCount; } } if (keyCount > 0) { resultArray.PrepLength(keyCount); foreach (KeyValue <keyType, int> result in resultCountDictionary.KeyValues) { if (result.Value == count) { resultArray.UnsafeAdd(result.Key); } } } } break; } return(resultArray); }