Re: ADTs in Euphoria
- Posted by Jeffrey Fielding <JJProg at CYBERBURY.NET> Dec 20, 2000
- 540 views
On Thu, 21 Dec 2000, S Ns wrote: > Hi I'm a newbie evaluating euphoria. > > Could someone briefly illustrate (or give a reference to some > info on) how one would implement a doubly-linked list or > binary search tree in Euphoria? > > Thanks in advance. > > --sns > Both of these are a little more difficult, and less effective implemented in Euphoria than implemented in C since Euphoria does not support pointers, and it already has a dynamic array - the sequence. Doubly linked lists can be completely replaced by a simple sequence, since sequences are dynamic arrays. Instead of dealing with pointers etc. you can just use append, prepend, & and subscripts to get the same functionality. Binary search trees can also be implemented in multi-dimensional sequences, though all the subscripting would probably make them rather ineffective. Of course, you could use allocate, peek, poke, and free to do a C-like implementation of the above. However, these are all rather expensive functions and it is much faster to use sequences and other built-in Euphoria data types. Jeff Fielding