Example #1
0
        public void Initialize(Memory <byte> nodeStatesWorkBuffer, int nodeCount)
        {
            int workBufferSize = GetWorkBufferSize(nodeCount);

            Debug.Assert(nodeStatesWorkBuffer.Length >= workBufferSize);

            _nodeCount = nodeCount;

            int edgeMatrixWorkBufferSize = EdgeMatrix.GetWorkBufferSize(nodeCount);

            _discovered.Initialize(nodeStatesWorkBuffer.Slice(0, edgeMatrixWorkBufferSize), nodeCount);
            _finished.Initialize(nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize, edgeMatrixWorkBufferSize), nodeCount);

            nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize * 2);

            _resultArray = SpanMemoryManager <int> .Cast(nodeStatesWorkBuffer.Slice(0, sizeof(int) * nodeCount));

            nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(sizeof(int) * nodeCount);

            Memory <int> stackWorkBuffer = SpanMemoryManager <int> .Cast(nodeStatesWorkBuffer.Slice(0, Stack.CalcBufferSize(nodeCount *nodeCount)));

            _stack.Reset(stackWorkBuffer, nodeCount * nodeCount);
        }
Example #2
0
 public static int GetWorkBufferSize(int nodeCount)
 {
     return(Stack.CalcBufferSize(nodeCount * nodeCount) + 0xC * nodeCount + 2 * EdgeMatrix.GetWorkBufferSize(nodeCount));
 }