コード例 #1
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="parser">参数解析</param>
        internal override void QueryEnd(ref OperationParameter.NodeParser parser)
        {
            switch (parser.OperationType)
            {
            case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(count); return;

            case OperationParameter.OperationType.ContainsKey:
                HashCodeKey <keyType> key;
                if (HashCodeKey <keyType> .Get(ref parser, out key))
                {
                    System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                    parser.ReturnParameter.ReturnParameterSet(dictionary != null && dictionary.ContainsKey(key));
                }
                return;

            case OperationParameter.OperationType.CreateShortPath:
                nodeType node = getNext(ref parser);
                if (node != null)
                {
                    node.CreateShortPath(ref parser);
                }
                return;
            }
            parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError;
        }
コード例 #2
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="parser"></param>
        private void remove(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary != null)
                {
                    nodeType node;
                    if (dictionary.TryGetValue(key, out node))
                    {
                        dictionary.Remove(key);
                        --count;
                        parser.SetOperationReturnParameter();
                        node.OnRemoved();
                        return;
                    }
                }
                parser.ReturnParameter.ReturnParameterSet(false);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
コード例 #3
0
 /// <summary>
 /// 获取下一个节点
 /// </summary>
 /// <param name="parser"></param>
 /// <returns></returns>
 private nodeType getNext(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         nodeType node;
         if (dictionary.TryGetValue(key, out node)) return node;
         parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
     }
     return null;
 }
コード例 #4
0
 /// <summary>
 /// 获取关键字
 /// </summary>
 /// <param name="parser"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 internal static bool Get(ref OperationParameter.NodeParser parser, out HashCodeKey <valueType> key)
 {
     if (parser.ValueData.Type == ValueData.Data <valueType> .DataType)
     {
         key = new HashCodeKey <valueType>(ValueData.Data <valueType> .GetData(ref parser.ValueData));
         return(true);
     }
     parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
     key = default(HashCodeKey <valueType>);
     return(false);
 }
コード例 #5
0
 /// <summary>
 /// 获取或者创建节点
 /// </summary>
 /// <param name="parser"></param>
 private void getOrCreateNode(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         if (!dictionary.ContainsKey(key))
         {
             dictionary.Set(key, nodeConstructor(this, ref parser));
             parser.IsOperation = true;
         }
         parser.ReturnParameter.ReturnParameterSet(true);
     }
     else parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
 }
コード例 #6
0
 /// <summary>
 /// 删除节点
 /// </summary>
 /// <param name="parser"></param>
 private void remove(ref OperationParameter.NodeParser parser)
 {
     keyType key;
     if (HashCodeKey<keyType>.Get(ref parser, out key))
     {
         nodeType node;
         if (dictionary.Remove(ref key, out node))
         {
             parser.SetOperationReturnParameter();
             node.OnRemoved();
         }
         else parser.ReturnParameter.ReturnParameterSet(false);
     }
     else parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
 }
コード例 #7
0
        /// <summary>
        /// 获取下一个节点
        /// </summary>
        /// <param name="parser"></param>
        /// <returns></returns>
        private nodeType getNext(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                nodeType node;
                if (fragmentDictionary.TryGetValue(key, out node))
                {
                    return(node);
                }
                parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
            }
            return(null);
        }
コード例 #8
0
 /// <summary>
 /// 查询数据
 /// </summary>
 /// <param name="parser">参数解析</param>
 internal override void QueryEnd(ref OperationParameter.NodeParser parser)
 {
     switch (parser.OperationType)
     {
         case OperationParameter.OperationType.GetCount: parser.ReturnParameter.ReturnParameterSet(dictionary.Count); return;
         case OperationParameter.OperationType.ContainsKey:
             keyType key;
             if (HashCodeKey<keyType>.Get(ref parser, out key)) parser.ReturnParameter.ReturnParameterSet(dictionary.ContainsKey(key));
             return;
         case OperationParameter.OperationType.CreateShortPath:
             nodeType node = getNext(ref parser);
             if (node != null) node.CreateShortPath(ref parser);
             return;
     }
     parser.ReturnParameter.ReturnType = ReturnType.OperationTypeError;
 }
コード例 #9
0
        /// <summary>
        /// 获取下一个节点
        /// </summary>
        /// <param name="parser"></param>
        /// <returns></returns>
        private nodeType getNext(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary != null)
                {
                    nodeType node;
                    if (dictionary.TryGetValue(key, out node))
                    {
                        return(node);
                    }
                }
                parser.ReturnParameter.ReturnType = ReturnType.NotFoundDictionaryKey;
            }
            return(null);
        }
コード例 #10
0
        /// <summary>
        /// 获取或者创建节点
        /// </summary>
        /// <param name="parser"></param>
        private void getOrCreateNode(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = fragmentDictionary.GetOrCreateDictionary(key);
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, nodeConstructor(this, ref parser));
                    ++fragmentDictionary.Count;
                    parser.IsOperation = true;
                }
                parser.ReturnParameter.ReturnParameterSet(true);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
コード例 #11
0
        /// <summary>
        /// 获取或者创建节点
        /// </summary>
        /// <param name="parser"></param>
        private void getOrCreateNode(ref OperationParameter.NodeParser parser)
        {
            HashCodeKey <keyType> key;

            if (HashCodeKey <keyType> .Get(ref parser, out key))
            {
                System.Collections.Generic.Dictionary <HashCodeKey <keyType>, nodeType> dictionary = dictionarys[key.HashCode & 0xff];
                if (dictionary == null)
                {
                    dictionarys[key.HashCode & 0xff] = dictionary = AutoCSer.DictionaryCreator <HashCodeKey <keyType> > .Create <nodeType>();
                }
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, nodeConstructor(this, ref parser));
                    ++count;
                    parser.IsOperation = true;
                }
                parser.ReturnParameter.ReturnParameterSet(true);
            }
            else
            {
                parser.ReturnParameter.ReturnType = ReturnType.ValueDataLoadError;
            }
        }
コード例 #12
0
 /// <summary>
 /// 判断是否相等
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(HashCodeKey <valueType> other)
 {
     return(HashCode == other.HashCode && Value.Equals(other.Value));
 }