Esempio n. 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));
            }
Esempio n. 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>());
 }
Esempio n. 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));
         }
     }
 }
Esempio n. 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);
            }
Esempio n. 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);
             }
         }
     }
 }
Esempio n. 6
0
        public static NodeEdges Clearance(NodeEdges e, uint value)
        {
            var mask = (NodeEdges)((ulong)value << 32);

            return((e & ~NodeEdges.ClearanceMask) | mask);
        }
Esempio n. 7
0
 public static uint Clearance(NodeEdges e) => (uint)((ulong)(e & NodeEdges.ClearanceMask) >> 32);
Esempio n. 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;
Esempio n. 9
0
 public static NodeEdges IsGrown(NodeEdges e, bool value) => value ? e | NodeEdges.IsGrown : e & ~NodeEdges.IsGrown;
Esempio n. 10
0
 public static bool IsGrown(NodeEdges e) => e.HasFlag(NodeEdges.IsGrown);
Esempio n. 11
0
 public static void SetEdges(NodeHandle a, NodeEdges e) => AllNodes.Set(a, e);
Esempio n. 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]));
        }
Esempio n. 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);
        }
Esempio n. 14
0
 public static bool HasFlag(NodeHandle n, NodeEdges flag) => (AllNodes.Get(n) & flag) != 0;
Esempio n. 15
0
 public void AddNode()
 {
     _nodes.Add(NodeFactory.CreateNode(this, NodeCount));
     NodeEdges.Add(new List <Edge>());
 }