November 2019
Beginner to intermediate
674 pages
15h
English
For a more meaningful example, we can see how we can adapt code that expects to operate on a double-ended queue when we don't have an implementation of such a structure ready.
The AdapterMain unit implements two methods, RotateLeft and RotateRight, as follows:
procedure TfrmAdapter.RotateLeft(const deque: IDeque<integer>);begin deque.PushBack(deque.PopFront);end;procedure TfrmAdapter.RotateRight(const deque: IDeque<integer>);begin deque.PushFront(deque.PopBack);end;
Both are using the following double-ended queue interface from Deque.Intf:
type IDeque<T> = interface function ...
Read now
Unlock full access