comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Array Syntax
Date: Fri, 29 Feb 2008 18:48:03 +0100
Date: 2008-02-29T18:48:02+01:00	[thread overview]
Message-ID: <1o27nkm125mme.1953k42k1r4aa$.dlg@40tude.net> (raw)
In-Reply-To: f62dad2b-1e64-4289-bd05-3ce7db98ffee@k2g2000hse.googlegroups.com

On Fri, 29 Feb 2008 07:19:06 -0800 (PST), ma740988@gmail.com wrote:

> Trying to garner a feel for Ada - while perusing texts - and I'm
> having slight difficulties understanding array syntax.
> 
>    Max_Num : constant := 6;
> 
>    type Pixel_Data is
>       record
>          Num_Of_Values        : Int32;
>          Is_Valid_Data           : Boolean;
>       end record;
> 
>    type Pixel_Number is Int16 range 1 .. Max_Num ;
>    type Pixel_Data_Array is array
>      ( Pixel_Number range 1 .. Max_Num  )
>      of Pixel_Data;
> 
> Pixel_Data_Array is an array 6 deep of composite type Pixel Data.  So
> far so good?
> 
> Now given:
> 
>    Frames_In_Buffer : constant := 35 ;
>    Buffer_Pixel_Data :
>      array ( Int32 range 1 .. Frames_In_Buffer )
>      of aliased Pixel_Data_Array ;
> 
> From the looks of this Buffer_Pixel_data is an array within an array.

Buffer_Pixel_Data is an anonymous array of arrays.

> On paper I'm having a hard time representing this in part becuase I'm
> having a hard time understanding how a multi-dimensional array can
> have two separate types.

It is a single-dimensional array which elements are single-dimensional
arrays. When you index it you get a Pixel_Data_Array. When you index that
once more, you get Pixel_Data.

A two-dimensional array would be:

type Pixel_Number is range 1..Max_Num;
type Frame_Number is range 1..Frames_In_Buffer;
type Image is array (Frame_Number, Pixel_Number) of Pixel_Data;

That is indexed by one index, which is a tuple of Frame_Number and
Pixel_Number.

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



  parent reply	other threads:[~2008-02-29 17:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-29 15:19 Array Syntax ma740988
2008-02-29 16:01 ` Ludovic Brenta
2008-02-29 17:16 ` Georg Bauhaus
2008-02-29 17:48 ` Dmitry A. Kazakov [this message]
2008-02-29 17:50 ` Jeffrey R. Carter
2008-03-04 16:18 ` ma740988
replies disabled

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