MATLAB Object-Oriented Programming

(Joyce) #1
head

head =

dlnode with properties:

Data: 1
Next: []
Prev: []

nextNode

nextNode =

dlnode with properties:

Data: 2
Next: []
Prev: []

You can remove these nodes by clearing the variables:

clear head nextNode

The delete Method

The delete method simply calls the clearList method:

methods (Access = private)
function delete(node)
clearList(node)
end
end

The delete method has private access to prevent users from calling delete when
intending to delete a single node. MATLAB calls delete implicitly when the list is
destroyed.

To delete a single node from the list, use the removeNode method.

Specialize the dlnode Class


The dlnode class implements a doubly linked list and provides a convenient starting
point for creating more specialized types of linked lists. For example, suppose that you
want to create a list in which each node has a name.

3 MATLAB Classes Overview

Free download pdf