comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: [Shootout] Spellcheck.adb
Date: Tue, 26 Apr 2005 00:27:29 +0100
Date: 2005-04-26T00:27:29+01:00	[thread overview]
Message-ID: <mailman.74.1114471678.24457.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <1114464642.518876.137610@f14g2000cwb.googlegroups.com>

At first sight the thing to improve is the hash function. The current 
function seems too expensive. Some time ago I had this problem. I 
invented a less expensive function with good dispersion. I don't have 
the code with me now, but it was as follows. Treat both the input and 
output values as bit strings X (1 .. M) and Y (1 .. N) respectively. 
(Use representation clauses, packed arrays, and unchecked conversion 
for this.) Make N small, say 16. Set Y bits to the value of X bits as 
follows:

if M > N, Y (J) = X (1 + (J - 1) * M / N), for J in 1 .. N

if M = N, Y = X

if M < N, initialize Y to all zeros,
  then let Y (1 + (I - 1) * N / M) = X (I), for I in 1 .. M

Another thing to improve may be the text input. Buffering with streams 
has proved faster than Text_IO.




  parent reply	other threads:[~2005-04-25 23:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-25 21:30 [Shootout] Spellcheck.adb albert.bachmann
2005-04-25 21:57 ` Spellcheck.adb Albert Bachmann
2005-04-25 23:27 ` Marius Amado Alves [this message]
2005-04-26 18:04 ` Spellcheck.adb Matthew Heaney
2005-04-26 19:36 ` [Shootout] Spellcheck.adb David Sauvage
2005-04-26 20:50   ` Spellcheck.adb Albert Bachmann
2005-04-27 15:11     ` Spellcheck.adb Matthew Heaney
2005-04-27 22:49       ` Spellcheck.adb Albert Bachmann
2005-04-27 23:35         ` Spellcheck.adb Marius Amado Alves
2005-04-27 23:58           ` Spellcheck.adb Albert Bachmann
2005-04-28  0:19             ` Spellcheck.adb Marius Amado Alves
2005-04-29 10:22               ` Spellcheck.adb Albert Bachmann
2005-04-28  0:58             ` Spellcheck.adb Matthew Heaney
2005-04-29 10:19               ` Spellcheck.adb Albert Bachmann
2005-04-28  0:41         ` Spellcheck.adb Matthew Heaney
2005-04-28 21:20           ` Spellcheck.adb Simon Wright
2005-04-29 10:05           ` Spellcheck.adb Albert Bachmann
2005-04-29 12:35             ` Spellcheck.adb Matthew Heaney
2005-04-26 21:21   ` Spellcheck.adb Albert Bachmann
2005-04-26 22:04     ` Spellcheck.adb David Sauvage
2005-04-26 20:36 ` [Shootout] Spellcheck.adb Dmitry A. Kazakov
2005-04-26 21:50   ` David Sauvage
2005-04-27  8:40     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox