Posts

Showing posts with the label data-structures

Double Linked List in Common Lisp

5 I want to implement a simple double linked list in SBCL with the following key structure (defstruct element (value 0 :type fixnum) (next nil :type element) (prev nil :type element)) The problem is, that it's impossible to instantiate the first element, because neither next nor prev may be nil. Their type is element and so they have to be an instance. The problem is basically easy to fix if I remove the type property. But the fact is, that this part of the programm needs to be really fast, so I want to give the optimizer a chance to make the best out of it. Is there any other way to specify the type of the member AND to make them nil? Or better: Is there a way to create a start instance with next and prev referencing the instance itself? ...