"Create a generic container. The elements in this container are iterateable both forward and backward. It means you can access at next, previous, fist and last element in O(1). "
Double_List is reasoned at Internal_List and Double_List
Internal_List is the core of this double linked list. Each Internal_List hold a previous pointer and the next pointer besides the actual Data. So you can iterate this list with Previous and Next. But objects of this class "do not know" the first and last element.
So the Double_List holds one Internal_List which is represented the current Position in the list in Anchor_Cursor. Additionally Double_List is kept the first and last position in the list in Anchor_First and Anchor_Last respectively. Now there exists 3 types of Methods:
Methods which are handled by Double_List without changing the internal structure This methods do not have any corresponding methods in Internal_List. That is e.g. First.
Methods which are only "handed over" to the Internal_List without changing the position of beginning and ending of the list This is e.g. Next.
Methods which are managed by Internal_List and manipulates pointer to beginning or to ending the list potentielly This is e.g. Add_At_Head or Remove. This methos are get this both as parameters and adapt it.
Is_Empty means here that the cursor is not in List. An access to the Anchor_Cursor (this represents the position pointer in the List) e.g. with Get_Data raised an Empty_List_Exception. Note:You have to gurantee that position of the cursor "is in list". If you have at least one element in the list you can do that with First or Last
To Iterate the list forward set the cursor at first position in the list with First. Now you can iterate the list with Next while you in list (check it with Is_Empty. If you want to access this list later do not forget to set the cursor back into list with First or Last!
To Iterate the list backward set the cursor at first position in the list with Last. Now you can iterate the list with Previous while you in list (check it with Is_Empty. If you want to access this list later do not forget to set the cursor back into list with First or Last!