예제 #1
0
파일: Result.cs 프로젝트: AutoCSer/AutoCSer
            /// <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;
            }
예제 #2
0
            internal void Add(keyType key, WordType wordType, ref ResultIndexArray indexs)
            {
                int count = indexs.Indexs.Length;

                WordType = wordType;
                Result.Add(key, indexs);
                if (count == 0)
                {
                    ++Count;
                }
                else
                {
                    Count += indexs.Indexs.Length;
                }
            }
예제 #3
0
 internal void Add(keyType key, WordType wordType, ref ResultIndexArray indexs)
 {
     Array[Index & ArrayPool.ArraySizeAnd].Add(key, wordType, ref indexs);
 }