Re: is there really no efficient way to delete an element from a list??
- To: mathgroup at smc.vnet.net
- Subject: [mg23951] Re: is there really no efficient way to delete an element from a list??
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sun, 18 Jun 2000 03:00:36 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <8icc9h$9nn@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, internal (deep in the C code of the kernel) the List[]s are true C arrays and not linked lists. There is no way to remove a element from a array and keep the array filled without copying the elements except the end. The only place to do it is the end of the array but this needs an additional overhead for the true length and the largest possible length. The only way you can try is a folded list for your stack {e1,{e2,{e3,{e4,{}}}} but than append is a bit harder. Regards Jens Martin Bauer wrote: > > hi, i tried to implement a queue with mathematica; > is it possible that there is no O(1) way to get > queue = Rest[queue] ?? > > it seems that mathematica uses call by value instead of call by reference > here; > i know that there are PrependTo[] and ApendTo[] for building the list; is > there any equivalent to these functions to remove elements? > > or is there another way to implement a stack or queue with constant time > access? >