
-----------------------------------
tum_twish
Thu Jun 05, 2003 10:35 am

Deleting elements in an array
-----------------------------------
Is it possible to delete an element (parition)of an array (ie. make it no value) given the index (subscript) of the element?

-----------------------------------
Martin
Thu Jun 05, 2003 10:49 am


-----------------------------------
Nope. Just set it to a flag value that you know isn't going to be used, or use linked lists

-----------------------------------
tum_twish
Thu Jun 05, 2003 10:53 am


-----------------------------------
what r linked lists?

-----------------------------------
Martin
Thu Jun 05, 2003 10:57 am


-----------------------------------
It's a really efficient way to store data.

Basically you have a pointer to the first memory location of a record, and then each subsequent record has a pointer to the next one in line

type list :
   record
     x,y : int %just to make the record hold something
     next : ^list %Pointer to the next node
   end record

you then have a variable var first : ^list and set that = to nil. Then, whenever you want to add a new element to the list, you allocate a new memory location for a new node, and add that to the end of the node. I'll write a tutorial on this later.

-----------------------------------
Blade
Thu Jun 05, 2003 11:19 am


-----------------------------------
i kinda thought he was talking about flexible arrays..

-----------------------------------
PaddyLong
Thu Jun 05, 2003 4:17 pm


-----------------------------------
flexible arrays wouldn't really work... they just resize the array, not reset it...
