From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Marek Newsgroups: comp.lang.ada Subject: Re: 2-dimensional view on 1 dimensional array Date: Tue, 25 Oct 2022 18:59:14 +0200 Organization: A noiseless patient Spider Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 25 Oct 2022 16:59:14 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="6825831ce1a782b2e8a677446fc70dd8"; logging-data="2204067"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18y40h8K+vYJI41wCmr4pzV" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cancel-Lock: sha1:7VByJ/LxNDb6IPfMeFADjNPXYWw= Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:64554 List-Id: I want just to know if it is possible to make different "view" on 1 dimensional array. And of course I meant not 2-dimensional array but array of arrays. Reason for that is that I want to use slicing on that view. Ok, here is full specification: generic type T is private; type T_Array is array (Natural range <>) of aliased T; type T_Array_Access is access all T_Array; package Buffers is type Row_Array is array (Natural range <>) of aliased T_Array_Access; type Row_Array_Access is access all Row_Array; type Buffer is tagged record Raw_Buffer : T_Array_Access := null; Rows_Table : Row_Array_Access := null; Rows : Natural := 0; Columns : Natural := 0; Step : Integer := 0; Max_Rows : Natural := 0; end record; procedure Init (This : in out Buffer; Buffer : T_Array_Access; Rows : Natural; Columns : Natural; Step : Integer); procedure Set_Value (This : in out Buffer; Value : T); function Get_Buffer (This : Rendering_Buffer) return T_Array_Access is (This.Buffer); function Get_Rows_Table (This : Rendering_Buffer) return Row_Array_Access is (This.Rows); function Get_Columns (This : Rendering_Buffer) return Natural is (This.Columns); function Get_Rows (This : Rendering_Buffer) return Natural is (This.Rows); function Get_Step (This : Rendering_Buffer) return Integer is (This.Step); function Move_Start (This : Rendering_Buffer; Col_Offset : Natural; Row_Offset : Natural) return T_Array_Access; function Row (This : Rendering_Buffer; R : Natural) return T_Array_Access; procedure Copy_From (This : in out Rendering_Buffer; Source : Rendering_Buffer); end Buffers; I consider this package to be a kind of template that I can apply to the raw data and get what it expects. That is why I am using access types. I know this is very C-ish but... thank you for your answers everybody Marek p.s. Be aware that this group is read not only by software engineers. Carpenters may also happen ... :)