using System; using System.Collections.Generic; using System.Text; namespace BrazilTimestampReconstruction { class ClockFit { LlseFit globalFit; // Local-Global Clock fit (if exists) Dictionary localAnchors; // Local-Local fits with other nodes Int16 roundNumber, numUpdates; // TODO : Reserved for later Set fitset; // Used to avoid cycles String segmentID; // current segment String path; // Stores the current best path string parentSegment; public ClockFit(String key) { localAnchors = new Dictionary(); roundNumber = -1; numUpdates = -1; this.segmentID = key; fitset = new Set(); fitset.Add(key); path = segmentID; } public RelativeFit InsertLocalAnchors(string key, double p, double q) { RelativeFit rfit; if (localAnchors.ContainsKey (key)) { rfit = localAnchors[key]; } else { rfit = new RelativeFit (); localAnchors.Add(key, rfit); } rfit.InsertNewAnchorPoint(p, q); return rfit; } /// /// This method add the links for those nodes /// which are neighbors but the parent nodeid /// is actually greater than the child nodeid. /// We use a pointer to the object in which the /// anchors are stored /// (i.e. parent nodeid lte child nodeid) /// /// public void InsertLinkWithoutAnchors(string key, RelativeFit rfit) { if (localAnchors.ContainsKey(key)) { return; } else { localAnchors.Add(key, rfit); } } public LlseFit GlobalFit { get { return globalFit; } set { globalFit = value; } } public Dictionary LocalAnchors { get { return localAnchors; } } public Int16 RoundNumber { set { roundNumber = value; } get { return roundNumber; } } public string ParentSegment { set { parentSegment = value; } get { return parentSegment; } } public void AddAncestor(string parKey) { fitset.Add(parKey); //fitset.Add(parKey, true); } public bool HasAncestor(string parKey) { return fitset.Contains (parKey); } public void AddAncestors (Set parset) { //this.fitset = parset.; fitset.Clear(); fitset = fitset + parset; fitset.Add(segmentID); } public void AddToPath(string currBest) { path = currBest + " " + this.segmentID; } public string Path { get { return path; } } public Set Fitset { set { fitset = value;} get { return fitset; } } } }