public void First() { if (s == 0) { IsDone = false; it = null; if (root == null) { s = 0; //no tree, no next } else if (root.Left != null) { s = 1; //we are in the left subtree it = new OysterIterator(root.Left); } else { s = 2; } } if (s == 0) { IsDone = true; Current = null; } }
public FranceTravel(BookingDatabase bookingDatabase, OysterDatabase oysterDatabase, ShutterStockDatabase shutterDatabase, TripAdvisorDatabase advisorDatabase, Random random) { this.booking = new BookingIterator(bookingDatabase); this.oyster = new OysterIterator(oysterDatabase); this.shutter = new ShutterStockIterator(shutterDatabase); this.advisor = new TripAdvisorIterator(advisorDatabase); this.random = random; }
public FranceReview(OysterIterator oyster) { while (this.user == null) { if (oyster.HasNext) { BSTNode node = oyster.GetNext; this.user = node.UserName; this.coment = node.Review; } else { oyster.Reset(); } } }
public void Next() { if (s == 0) { IsDone = true; Current = null; return; } else if (s == 2) { if (root.Right == null) { s = 0; } else { s = 3; it = new OysterIterator(root.Right); } Current = root; return; } it.Next(); var node = it.Current; if (node == null) { if (s == 1) { s = 2; } else // right node returned null { s = 0; } Next(); node = Current; } Current = node; return; }