Re: Algorithm



"Roedy Green" <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx> wrote in
message news:81p8m15lh39o6tcrkov256qi7npiq7vnc4@xxxxxxxxxx
> On Sat, 29 Oct 2005 19:59:36 -0600, "Luc The Perverse"
> <sll_noSpamlicious_z_XXX_m@xxxxxxxxxx> wrote, quoted or indirectly
> quoted someone who said :
>
>>
>>Yes that was the plan. My problem is coming when I want to delete the
>>same
>>object from each of the three arrays at the same time. (I will have
>>found
>>it by looking through only one of the arrays.
>
> Sorted arrays are not insert/delete friendly. They are a batch-think
> tool.
>
> Have a look at the ArrayList.remove method. You can do it by index or
> by object. By object requires a linear scan of each of the three
> arrays. There is then a block move to shuffle all high elements down
> one in each array.
>
> If this is something you don't do often, delete the object from the
> original pool, recreate the three arrays and resort them. This may
> sound extravagent, but the same code will work no matter how many
> arrays and sub collections you create. You don't need to carefully
> maintain the delete logic.
>
> Another approach is instead of removing the object, just invalidate it
> so that it is ignored ever after, including any rebuild of the array
> where it will be permanently dropped.
>
> You might be interested in my SortedArray class that handles many of
> these things for you.
>
> See http://mindprod.com/products1.html#SORTED

Thank you

--
LTP

:)


.



Relevant Pages

  • Re: About Sorting
    ... i just have three sorted arrays,and i have to merge all three arrays ... >>i dont know its algorithem. ...
    (comp.lang.c)
  • Re: Join Multiple Arrays using equals or comparable
    ... >implemented a sort merge join of 3 or more sorted arrays. ... On joining ...
    (comp.lang.java.programmer)
  • Re: Algorithm
    ... >Yes that was the plan. ... >object from each of the three arrays at the same time. ... Sorted arrays are not insert/delete friendly. ... recreate the three arrays and resort them. ...
    (comp.lang.java.programmer)
  • Re: About Sorting
    ... >is there any way to merge three sorted arrays into a sorted file, ... >i dont know its algorithem. ...
    (comp.lang.c)
  • Re: FFTW and Fortran.
    ... Kamaraju Kusumanchi wrote... ... > arrays and plan. ... > The modified program is ...
    (comp.lang.fortran)