From: Martin Trenkmann <martin.trenkmann@posteo.de>
Subject: Implementing character sets for Wide_Character
Date: Fri, 06 Mar 2015 19:01:33 +0100
Date: 2015-03-06T19:01:33+01:00 [thread overview]
Message-ID: <mdcq1u$4s6$1@news.albasani.net> (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
next reply other threads:[~2015-03-06 18:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 18:01 Martin Trenkmann [this message]
2015-03-06 18:15 ` Implementing character sets for Wide_Character 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox