public string AddToDisk(IDisc discelements) { DiscsElements.Add(discelements); if (DiscsElements.Count > _count) { return("On disk may be saved <20 elements"); } return("On disk saved " + DiscsElements.Count); }
private void ReconnectDown(IDisc disk) { Parallel.ForEach(disk.Nodes, node => { var outsideNode = node.ConnectedNodes.First(n => n.Parent != node.Parent); Node.Disconnect(node, outsideNode); Node.Connect(node, (INode)outsideNode.Previous); }); }
static private ulong discDiff(IDisc disc, int[] lengths) { if (disc == null || lengths == null || disc.Offsets.Count != lengths.Length) { return(UInt64.MaxValue); } return(disc.Offsets.Zip(disc.Offsets.Skip(1), (c, n) => n - c).Concat(new int[1] { disc.Sectors - disc.Offsets.LastOrDefault() }).Zip(lengths).Aggregate(0UL, (s, v) => { ulong d = (ulong)(v.First - v.Second); s += d * d; return s; })); }
//-------------- Rotinas public DiscReader(IDisc disc) { this.disc = (Disc)disc; device = this.disc.device; context = IOManager.CreateIOContext(this.device.Name + disc.Code, this.device.device.Path, FileAccess.ReadWrite, FileShare.None, 0, FileMode.Open, EFileAttributes.NoBuffering); Lock(); Seek(0); Unlock(); }
public static void Connect(IDisc disc1, IDisc disc2) { if (disc1.Nodes.Count != disc2.Nodes.Count) { throw new Exception("Your discs dont have the same number of connections!"); } for (int i = 0; i < disc1.Nodes.Count; i++) { Node.Connect(disc1.Nodes[i], disc2.Nodes[i]); } }
public void PlaceDisc(IDisc disc) { if (CurrentNumberOfDiscs >= MaxDiscs) { throw new InvalidOperationException("This peg is full"); } if (TopDisc != null && TopDisc.Size <= disc.Size) { throw new InvalidOperationException("Cannot place bigger disc on top of smaller disc"); } _discs.Add(disc); }
public HeadMovingDiscState(IDisc disc) : base(disc) { }
static private bool discMatch(IDisc disc, int[] lengths) { return(disc.Offsets.Zip(disc.Offsets.Skip(1), (c, n) => n - c).Concat(new int[1] { disc.Sectors - disc.Offsets.LastOrDefault() }).SequenceEqual(lengths)); }
public RequestHandlingDiscState(IDisc disc) : base(disc) { }
public DoubleSidedDisc(int numberOfConnections) { this.LeftDisc = new Disc(numberOfConnections); this.RightDisc = new Disc(numberOfConnections); }
protected AbstractDiscState(IDisc disc) { Disc = disc; }