I’ve been looking at the implementation of linked lists and, at the moment, I don’t think the reference language is sufficiently complex to support an implementation of either a single or double linked list.
To do the typical implementation, with data, pointer (which is an implementation of nested objects) would require something like this:
CLASS node IS { INTEGER data, node pointer}
METHODS
CONSTRUCTOR (INTEGER data, node pointer)
SET THIS.data TO data
IF pointer = NULL THEN
SET THIS.pointer TO NULL
ELSE
SET THIS.pointer TO pointer
END IF
END CONSTRUCTOR
FUNCTION get_data()
RETURN THIS.data
END FUNCTION
FUNCTION get_next()
RETURN THIS.pointer
END FUNCTION
FUNCTION set_next(pointer)
SET THIS.pointer TO pointer
END FUNCTION
END CLASS
CLASS LinkedList IS {node head}
METHODS
CONSTRUCTOR (node head)
SET THIS.head TO NULL
END CONSTRUCTOR
END CLASS
Any thoughts? The reference language should be able to represent all the required algorithms at this level. Am I missing something?