// Search given shape and set current to it if found public bool Search(AShape s) { if (s != null) { DoublyNode t = current; Set_current_first(); for (bool cond = !Is_empty(); cond; cond = Step_forward()) { if (Current.Shape == s) { return(true); } } current = t; } Notify(); return(false); }
// Add new shape to the front of the list public bool Push_front(AShape shape) { if (shape == null) { return(false); } DoublyNode fresh = new DoublyNode(shape); if (count > 0) { head.prev = fresh; fresh.next = head; head = fresh; } else { tail = fresh; head = fresh; } current = head; ++count; Notify(); return(true); }
// Add new shape to the back of the list public bool Push_back(AShape shape) { if (shape == null) { return(false); } DoublyNode fresh = new DoublyNode(shape); if (count > 0) { fresh.prev = tail; tail.next = fresh; tail = fresh; } else { tail = fresh; head = fresh; } current = tail; ++count; Notify(); return(true); }
public DoublyNode(AShape shape) { this.shape = shape; prev = null; next = null; }