comp.lang.ada
 help / color / mirror / Atom feed
* Implementing character sets for Wide_Character
@ 2015-03-06 18:01 Martin Trenkmann
  2015-03-06 18:15 ` Bob Duff
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Martin Trenkmann @ 2015-03-06 18:01 UTC (permalink / raw)


I need to implement a containment check for Wide_Character in a wide character set. I have two approaches in mind.

1. Using an array type similar to Ada.Strings.Maps.Character_Set.

   type Wide_Character_Set is array (Wide_Character) of Boolean with Pack;
   
   XYZ_Charset_Set : constant Wide_Character_Set
     := (Wide_Character'Val (100) .. Wide_Character'Val (900) => True,
         others                                               => False);

2. Using a function with a case statement.

   function Is_In_XYZ_Charset_Set (Item : Wide_Character) return Boolean is
   begin
      case Item is
         when Wide_Character'Val (100) .. Wide_Character'Val (900) => return True;
         when others                                               => return False;
      end case;
   end Is_In_XYZ_Charset_Set;


I know that using an array will consume more memory, but with the Pack aspect it should only be 8 KB - please correct me if I am wrong. The function approach is more memory friendly, but might be a bit slower as an array lookup.

Should I definitely avoid one of the solutions or is just a matter of available memory?

Thanks for your help.

Martin


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-06 22:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 18:01 Implementing character sets for Wide_Character Martin Trenkmann
2015-03-06 18:15 ` Bob Duff
2015-03-06 21:02   ` Martin Trenkmann
2015-03-06 18:18 ` G.B.
2015-03-06 21:06   ` Martin Trenkmann
2015-03-06 22:21     ` Bob Duff
2015-03-06 19:24 ` Dmitry A. Kazakov
2015-03-06 21:48 ` Jeffrey Carter

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