Skip to content

Design Choises

Anders Jansson edited this page Nov 27, 2016 · 1 revision

This is a discussion of why some design choised were made.

The structural element

The list and the structural element in the list and the list is the same data type. This could potentially be confusing as the element could sometimes be the whole list. But it is also a part of making the implementation smart with regards to insert and remove.

Head is "part" of the list

The list (or the head of the list) is part in the list to make implementation of insert and delete smart. This is part of making the implementation smart with regards to insert and remove.

Deleting contents of the list

The list is not responsible for deleting the elements in the list. So on deletion a function that destroys the actual element is needed.

This will allow us to create a shadow copy or a clone of the list. The list can not know by itself if it should destroy the element when we remove it from the list. If this was implemented we would have to do reference counting on each element (in the element itself) and this is not practical.

Storage to the most generic type

The data type stored in the list is a pointer to a void. This allows us to store anything in the list. We could implement a type where we store data in the struct DLL. This would stop us from allowing swapping elements which is a critical part of the sorting and other algorithms.

Namespace is _dllist

The namespace for the list interface is _dllist appended to each function. We have to stay out of other programs definition of functions so that they don't interfere with each other.