MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: is there really no efficient way to delete an element from a list??


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?
>


  • Prev by Date: Re: is there really no efficient way to delete an element from a list??
  • Next by Date: Re: Newbie question: pairswise function application
  • Previous by thread: Re: is there really no efficient way to delete an element from a list??
  • Next by thread: Re: is there really no efficient way to delete an element from a list??