comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to use associative arrays in Ada 2005?
Date: Mon, 27 Nov 2006 22:11:52 +0100
Date: 2006-11-27T22:11:50+01:00	[thread overview]
Message-ID: <1kxzfampqtgkz.6gzp3w8j002$.dlg@40tude.net> (raw)
In-Reply-To: 1164657223.760376.158200@j72g2000cwa.googlegroups.com

On 27 Nov 2006 11:53:43 -0800, Matthew Heaney wrote:

> Dmitry A. Kazakov wrote:
>>
>> That depends on each concrete case. Arrays of arrays have advantages and
>> disadvantages. It is to expect a performance penalty in terms of both space
>> and time for an hash of hash of hash vs. simple hash. Clearly, instead of
>> one look-up you are doing three.
> 
> Yawn.  A hash-table look-up is O(1).  It's like trying to argue that
> you'll lose weight by only eating 1 pea instead of 3 peas for dinner...

... asymptotically under certain conditions, which might be or not met in a
real case.

Also:

1. Insertion and deletion in sparse 3D arrays organized in hashes of hashes
might lead to an eager allocation and deallocation of subordinated hashes.
Shuffling memory is not a pea. In some cases it is a disaster.

2. Finding an optimal set of hash functions (and that is 1+n+n*m
functions!) might turn quite difficult, depending on how items are
distributed in 3D space. You might have a relatively evenly distributed
items in 3D, which awfully distributed in 2D and 1D planes.

3. You don't mention memory, for a good reason. Hashes are known space
eaters. And you have n**2 of them!

The bottom line is - I think a good advice to a student learning Ada, and
the Ada's way (tm) is to factor out a clean interface to his 3D array
first, and hide the implementation (be it a hash of hashes or anything
else). This might be obvious for Ada programmers, but people coming with
the background in other languages tend to think in terms of implementation.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2006-11-27 21:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 10:11 How to use associative arrays in Ada 2005? snoopysalive
2006-11-21 11:49 ` Georg Bauhaus
2006-11-21 14:18 ` Matthew Heaney
2006-11-21 23:35   ` snoopysalive
2006-11-23 19:27     ` snoopysalive
2006-11-23 19:40       ` Georg Bauhaus
2006-11-24  0:33       ` Georg Bauhaus
2006-11-24 11:49         ` Matthew Heaney
2006-11-24  8:27       ` Dmitry A. Kazakov
2006-11-24 11:51         ` Matthew Heaney
2006-11-26 19:05           ` snoopysalive
2006-11-26 20:30             ` Matthew Heaney
2006-11-27  9:15             ` Dmitry A. Kazakov
2006-11-27 19:53               ` Matthew Heaney
2006-11-27 21:11                 ` Dmitry A. Kazakov [this message]
2006-11-27 21:52                   ` Matthew Heaney
2006-11-28  8:29                     ` Alex R. Mosteo
2006-11-28 13:19                       ` Matthew Heaney
2006-11-28  8:34                     ` Dmitry A. Kazakov
2006-11-28 13:21                       ` Matthew Heaney
2006-11-27 21:08             ` Simon Wright
2006-11-27 22:22               ` Matthew Heaney
2006-11-27 22:58                 ` Simon Wright
2006-11-28  1:55                   ` Matthew Heaney
2006-11-24 11:35       ` Matthew Heaney
replies disabled

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