public bool deleteUser(string userName) { Node willBeRemoved = this.Find(userName); if (willBeRemoved != null) { if (willBeRemoved == willBeRemoved.parent) { mainNode = null; return(true); } Node last = FindLast(); if (last != null) { User temp = willBeRemoved.value; willBeRemoved.value = last.value; last.value = temp; if (last.parent.right != null) { last.parent.right = null; } else { last.parent.left = null; } MaxHeap.Sort(willBeRemoved); this.SortFromMiddle(willBeRemoved); return(true); } } return(false); }
public Tree(string FileName) { this.Categories = new List <Category>(); var lines = File.ReadLines("rezervasyon.txt"); foreach (var line in lines) { var args = line.Split(','); var categoryNames = args.LastOrDefault(); this.CreateCategoryIfDoesntExist(categoryNames); var currentCategory = FindCategoryByName(categoryNames.Split(':').LastOrDefault()); var userName = args.FirstOrDefault(); MaxHeap.Node InsertedOrFounded = currentCategory.Users.InsertOrFind(new User(userName)); var parserRule = CultureInfo.InvariantCulture.NumberFormat; Reservation newReservation = new Reservation(args[1], args[2], float.Parse(args[3], parserRule), float.Parse(args[4], parserRule), args[5]); InsertedOrFounded.value.Reservations.Add(newReservation); MaxHeap.Sort(InsertedOrFounded); } Console.WriteLine("Tree successfully created."); }