From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a15ffcec4cedcad,start X-Google-Attributes: gid103376,public From: Arash Vahidi Subject: help: String Sets in ADA??? Date: 1998/09/25 Message-ID: <360B9AFA.1F99D1CD@ios.chalmers.se>#1/1 X-Deja-AN: 394720716 Content-Transfer-Encoding: 7bit Organization: Chalmers University of Technology Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-09-25T00:00:00+00:00 List-Id: Hi' everyone I'm an Ada-newbie and have a newbie question for you older guys : How do you write a String-Set in adda without knowing the range of used strings?? Here is my code, but lloks like I get Cosntraint_Error as soon as I make an assigment (see the code). Can I use some kind of pointers here ?? If yes, how?? (I tried every forms of "access" and "'address" combinations I could think of) If you come up with somthing, please let me know (vahidi@cd.chalmers.se) Thanks for any help /Arash ---------------------------------- with Ada.Text_Io; use Ada.Text_Io; package body String_Set is type Node; type Node_Pointer is access Node; -- subtype String_Pointer is String(1..1024); -- type String_Pointer is new String(1..1024); type Node is record Object : String( 1..1024 ); -- Object : String_Pointer; Next : Node_Pointer; end record; First : Node_Pointer; procedure Init is begin First := null; end; procedure Insert( Object : in String) is Tmp : Node_Pointer; begin if in_Set( Object) = true then return; end if; if First = null then First := new Node; -- First.Object := String_Pointer(Object); First.Object := object; First.Next := null; else Tmp := First; loop exit when Tmp.Next = null; Tmp := Tmp.Next; end loop; Tmp.Next := new Node; Tmp := Tmp.Next; Tmp.Object := Object; Tmp.Next := null; end if; end; function Is_Empty return Boolean is begin return First = null; end; function In_Set(Object : in String) return Boolean is Tmp : Node_Pointer; begin Tmp := First; loop exit when Tmp = null; if Tmp.Object = Object then return True; end if; Tmp := Tmp.Next; end loop; return False; end; end String_Set; ----------------------------------