It still doesn't remove the need for a remove
function. Also, you can just call delete for the .all
array since its associative, but the children array is
ordinal, so you could slim down the removeFromArray to
only work for ordinal arrays and the associative array
can be deleted using the delete function. However, I
do not see that this would provide to much of a speed
boost though because I don't believe that associative
arrays go through a loop inside the removeFromArray
function.
Robert
--- Bart Bizon <[EMAIL PROTECTED]> wrote:
> Well, you could do it an alternate way.
> You could add a generic function to the Array
> object, for deleting items correctly.. i.e. deleting
> an item and redistributing the array by moving the
> adjacent items down a step.
> Something like:
>
> Array.prototype.deleteItem=function(item){
> for(var i=0,n=0;i<this.length;i++){
> if(this[i]!=this[item]) this[n++]=this[i]
> }
> this.length=this.length-1
> }
>
> /////////////////////////////////
>
> var a=[1,2,3,4,5]
> alert(a +" "+a.length)
> a.deleteItem(2)
> alert(a +" "+a.length)
>
>
> Some extra work is needed for accociative arrays..
> but this is a great way of extending Array
> functionality, and keeping functions dealing with
> "lists" and "stacks" general.
>
> / Bart
>
> -----Ursprungligt meddelande-----
> Fr�n: Scott Andrew LePera <[EMAIL PROTECTED]>
> Till: [EMAIL PROTECTED]
> <[EMAIL PROTECTED]>
> Datum: den 14 december 2000 20:24
> �mne: Re: [Dynapi-Dev] deleteFromArray
>
>
> >> hmm, so a delete array[element] will leave a gap
> instead of removing the
> >> element and move all "higher" elements down one
> step ?
> >
> >Yes, Brandon is correct in this. That's one of the
> reasons why
> >removeFromArray was created in the first place. It
> keeps ordinal arrays
> >in the correct order when you remove an element.
> >
> >--
> >scott andrew lepera
> >-----------------------------------
> >web stuff: www.scottandrew.com
> >music stuff: www.walkingbirds.com
> >_______________________________________________
> >Dynapi-Dev mailing list
> >[EMAIL PROTECTED]
>
>http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
>
> _______________________________________________
> Dynapi-Dev mailing list
> [EMAIL PROTECTED]
>
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev