public override void FillFromFile(string fileDir) { using (System.IO.StreamReader file = new System.IO.StreamReader(fileDir)) { if (!file.EndOfStream) { root = new Node(new DatePrice(file.ReadLine())); size++; } for (int i = 1; !file.EndOfStream; i++) { DatePrice left = new DatePrice(file.ReadLine()); if (!file.EndOfStream) { DatePrice right = new DatePrice(file.ReadLine()); new Node(GetNodeByIndex(i), left, right); size += 2; } else { new Node(GetNodeByIndex(i), left); size++; } } } }
public void add(DatePrice obj) { fileStreamData.Seek(size * 20, SeekOrigin.Begin); writerData.Write(obj.date); //writes data of element writerData.Write(obj.price); fileStreamTree.Seek(size * 12, SeekOrigin.Begin); //creates node writerTree.Write(size * 20); writerTree.Write(0); writerTree.Write(0); size++; }
public void add(int parentNodeAddress, DatePrice left) { fileStreamData.Seek(size * 20, SeekOrigin.Begin); writerData.Write(left.date); //writes data of left element writerData.Write(left.price); fileStreamTree.Seek(parentNodeAddress + 4, SeekOrigin.Begin); writerTree.Write(size * 12); //writes address of left node fileStreamTree.Seek(size * 12, SeekOrigin.Begin); writerTree.Write(size * 20); //creates left node writerTree.Write(0); writerTree.Write(0); size++; }
public override void FillFromFile(string fileDir) { using (System.IO.StreamReader file = new System.IO.StreamReader(fileDir)) { if (!file.EndOfStream) { add(new DatePrice(file.ReadLine())); } for (int i = 1; !file.EndOfStream; i++) { DatePrice left = new DatePrice(file.ReadLine()); if (!file.EndOfStream) { DatePrice right = new DatePrice(file.ReadLine()); add(GetNodeAdress(i), left, right); } else { add(GetNodeAdress(i), left); } } } }
public int CompareTo(object obj) { DatePrice dp = (DatePrice)obj; return(price.CompareTo(dp.price)); }
public Node(Node parent, DatePrice left) { parent.left = new Node(left); }
public Node(Node parent, DatePrice left, DatePrice right) { parent.left = new Node(left); parent.right = new Node(right); }
public Node(DatePrice Obj) { obj = Obj; }