Ejemplo n.º 1
0
        private void InsertSite(SiteEvent site)
        {
            var newArcA = new Arc {
                Site = site, LeftNeighbour = site
            };
            var newArcB = new Arc {
                Site = site, LeftNeighbour = site
            };

            var newNodeA      = InsertIntoSkiplist(newArcA);
            var newNodeB      = InsertIntoSkiplist(newArcB);
            var neighbourhood = FindNeighbourhoodOf(newNodeA);

            neighbourhood[3].Site = neighbourhood[1].Site;

            neighbourhood[1].LeftNeighbour = neighbourhood[0].Site;
            neighbourhood[2].LeftNeighbour = neighbourhood[1].Site;
            neighbourhood[3].LeftNeighbour = neighbourhood[2].Site;
            neighbourhood[4].LeftNeighbour = neighbourhood[3].Site;

            PotentialCircleEvents.Add(new CircleEvent(neighbourhood[0], neighbourhood[1], neighbourhood[2]));
            PotentialCircleEvents.Add(new CircleEvent(neighbourhood[2], neighbourhood[3], neighbourhood[4]));

            NewArcs.Add(new List <IArc> {
                neighbourhood[2], neighbourhood[3]
            });
        }
Ejemplo n.º 2
0
        private void InsertFirstSite(SiteEvent site)
        {
            var newArc = new Arc {
                Site = site, LeftNeighbour = site
            };

            InsertIntoSkiplist(newArc);
        }
Ejemplo n.º 3
0
        private void InsertSecondSite(SiteEvent site)
        {
            var oldArc = _arcs.First();
            var newArc = new Arc {
                Site = site, LeftNeighbour = oldArc.Site
            };

            oldArc.LeftNeighbour = site;

            InsertIntoSkiplist(newArc);
            NewArcs.Add(new List <IArc> {
                newArc, oldArc
            });
        }
Ejemplo n.º 4
0
 public void Insert(SiteEvent site)
 {
     if (Count == 0)
     {
         InsertFirstSite(site);
     }
     else if (Count == 1)
     {
         InsertSecondSite(site);
     }
     else
     {
         InsertSite(site);
     }
 }