Re: Fast appending and sorting of alot of short strings

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 9 Oct 2004, at 2:35, Pete Lomax wrote:

> 
> 
> On Wed, 6 Oct 2004 07:30:31 -0700, codepilot Gmail Account
> <codepilot at gmail.com> wrote:
> 
> >Can somone give me some good theory to get this to go fast?
> I was going to experiment with this a little, but got sidetracked & it
> does not seem like I will get round to it. Still, I'll comment:
> >there is a sequence and it gets searched alot, and also appended to.
> >I thought that using a hash_find for search was good, but then it has
> >to be sorted.
> The point of using a hash is that you do not sort the main table.
> Have a play with jiri's hash tables in the archives.
> 
> If I assume you try that and don't like it:
> 
> 1) If you have a big table that gets added to alot, then it is far
> better to use the following scheme:
> 
> sequence table	table=repeat(0,64)
> integer tabused	tabused=0
> ...
>  if tabused=length(table) then
>   table&=repeat(0,64)
>  end if
>  tabused+=1
>  table[tabused]=<blah>	-- see next
> 
> 2) In order to keep the table sorted, you are currently using:
> 
>  seq[1..current]&{query}&seq[current+1..len]
> 
> Instead try:
> 
>  table[current+1..tabused]=table[current..tabused-1]

But you are dropping the last t abused element of t able, aren't you? Or is it 
spare space preappended to table?
>  table[current]=query

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu