Re: Algorithm
- From: "Luc The Perverse" <sll_noSpamlicious_z_XXX_m@xxxxxxxxxx>
- Date: Sun, 30 Oct 2005 09:38:43 -0700
"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
:)
.
- References:
- Re: Algorithm
- From: Roedy Green
- Re: Algorithm
- Prev by Date: apache ant
- Next by Date: Check out the new Blog directory
- Previous by thread: Re: Algorithm
- Next by thread: Re: Sound Quality In Sound API
- Index(es):
Relevant Pages
|