Example #1
0
 public override V ConstructNodeContext <N>(int nodePosition, NodeState nodeState, NodeFactory <N> nodeFactory)
 {
     lock (this.NodeStateContextCache)
     {
         var stateHash = nodeState.GetHashCode();
         if (this.NodeStateContextCache.ContainsKey(nodePosition))
         {
             var stateHashSet = this.NodeStateContextCache[nodePosition];
             if (stateHashSet.ContainsKey(stateHash))
             {
                 return(this.NodeStateContextCache[nodePosition][stateHash]);
             }
             var constructedNodeContext = base.ConstructNodeContext(nodePosition, nodeState, nodeFactory);
             this.NodeStateContextCache[nodePosition].Add(stateHash, constructedNodeContext);
             return(constructedNodeContext);
         }
         else
         {
             var constructedNodeContext = base.ConstructNodeContext(nodePosition, nodeState, nodeFactory);
             var newDictionary          = new Dictionary <int, V>()
             {
                 { stateHash, constructedNodeContext }
             };
             this.NodeStateContextCache.Add(nodePosition, newDictionary);
             return(constructedNodeContext);
         }
     }
 }
Example #2
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (NodeState != global::NodeState.Unset)
        {
            hash ^= NodeState.GetHashCode();
        }
        if (NodeAddress.Length != 0)
        {
            hash ^= NodeAddress.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }