Example #1
0
            public NodeEdges AddOrUpdate(NodeHandle n, NodeEdges newValue, Func <NodeHandle, NodeEdges, NodeEdges> valueFactory)
            {
                RegionHandle r = Region(n);

                recentRegions.AddOrUpdate(r, TotalTime.ElapsedMilliseconds);
                SetDirty(r);
                return(Regions.GetOrAdd(r, regionFactory).AddOrUpdate(n, newValue, valueFactory));
            }
Example #2
0
 public void AddNode(Node node)
 {
     if (node.Graph != this || node.Index != NodeCount)
     {
         throw new InvalidOperationException();
     }
     _nodes.Add(node);
     NodeEdges.Add(new List <Edge>());
 }
Example #3
0
 public static IEnumerable <NodeHandle> Edges(NodeHandle a, NodeEdges e)
 {
     for (int i = 0; i < edgeOffsets.Length; i++)
     {
         if (e.HasFlag((NodeEdges)(1ul << i)))
         {
             yield return(AddEdgeOffset(a, i));
         }
     }
 }
Example #4
0
            public void Set(NodeHandle n, NodeEdges e)
            {
                RegionHandle r = Region(n);

                Regions
                .GetOrAdd(r, regionFactory)
                .AddOrUpdate(n, e, (k, o) => e);
                recentRegions.AddOrUpdate(r, TotalTime.ElapsedMilliseconds);
                SetDirty(r);
            }
Example #5
0
 public static void PropagateClearance(Queue <NodeHandle> queue)
 {
     while (queue.TryDequeue(out NodeHandle n))
     {
         NodeEdges nEdges = GetEdges(n);
         uint      c      = Clearance(nEdges);
         foreach (NodeHandle e in Edges(n, nEdges))
         {
             uint d = Clearance(e);
             if (d == 0 || d > c + 1)
             {
                 Clearance(e, c + 1);
                 queue.Enqueue(e);
             }
             else if (d < c - 1)
             {
                 Clearance(n, d + 1);
                 queue.Enqueue(n);
             }
         }
     }
 }
Example #6
0
        public static NodeEdges Clearance(NodeEdges e, uint value)
        {
            var mask = (NodeEdges)((ulong)value << 32);

            return((e & ~NodeEdges.ClearanceMask) | mask);
        }
Example #7
0
 public static uint Clearance(NodeEdges e) => (uint)((ulong)(e & NodeEdges.ClearanceMask) >> 32);
Example #8
0
 public static bool IsCover(NodeHandle a) => HasFlag(a, NodeEdges.IsCover);         // AllEdges.TryGetValue(a, out var flags) && (flags & NodeEdges.IsCover) > 0;
 public static NodeEdges IsCover(NodeEdges e, bool value) => value ? e | NodeEdges.IsCover : e & ~NodeEdges.IsCover;
Example #9
0
 public static NodeEdges IsGrown(NodeEdges e, bool value) => value ? e | NodeEdges.IsGrown : e & ~NodeEdges.IsGrown;
Example #10
0
 public static bool IsGrown(NodeEdges e) => e.HasFlag(NodeEdges.IsGrown);
Example #11
0
 public static void SetEdges(NodeHandle a, NodeEdges e) => AllNodes.Set(a, e);
Example #12
0
        public static NodeEdges AddEdge(NodeEdges e, NodeHandle a, NodeHandle b)
        {
            long d = (long)((ulong)b & handleMask) - (long)((ulong)a & handleMask);

            return(!whichEdgeBit.ContainsKey(d) ? e : e | (NodeEdges)(1ul << whichEdgeBit[d]));
        }
Example #13
0
        public static bool HasEdge(NodeEdges e, NodeHandle a, NodeHandle b)
        {
            long d = (long)((ulong)b & handleMask) - (long)((ulong)a & handleMask);

            return(whichEdgeBit.ContainsKey(d) ? e.HasFlag((NodeEdges)(1ul << whichEdgeBit[d])) : false);
        }
Example #14
0
 public static bool HasFlag(NodeHandle n, NodeEdges flag) => (AllNodes.Get(n) & flag) != 0;
Example #15
0
 public void AddNode()
 {
     _nodes.Add(NodeFactory.CreateNode(this, NodeCount));
     NodeEdges.Add(new List <Edge>());
 }