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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2d76c4749a82ef0b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-24 13:28:40 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!d9c68f36!not-for-mail Message-ID: <3F998B6D.8040305@noplace.com> From: Marin David Condic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Strings Fixed, Bounded, and Counted. Performance Inquiry. References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 24 Oct 2003 20:28:40 GMT NNTP-Posting-Host: 209.165.26.166 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1067027320 209.165.26.166 (Fri, 24 Oct 2003 16:28:40 EDT) NNTP-Posting-Date: Fri, 24 Oct 2003 16:28:40 EDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:1622 Date: 2003-10-24T20:28:40+00:00 List-Id: It may depend on your implementation, but Bounded strings ought to give you basically what you are looking for. It has a fixed maximum allocation and it maintains some sort of counter to know how long the actual content is. They have the down side that all strings must have the same maximum size in order to be compatible, but unless you wanted something dynamic, this shouldn't be a really bad limitation. Unbounded_String has got to do something similar - store a counter for the actual length. They have the advantage of growing as you need them to but would have a speed penalty. Or you could just use a garden variety fixed size String and cobble something together for yourself. It would just be a record with a counter and possibly a pointer to an actual fixed length string. Its not as wonderful an answer as one of the built-in packages, but you might get the utility you want as a result. (Id est, allocating only the space you actually need to store the string, flexible upper bounds & whatever sort of comparison or other operations you want to support.) You'd probably make heavy use of Ada.Strings.Fixed in the process. MDC Freejack wrote: > I'm currently tooling around with the various standard strings packages > And I began wondering if anyone has written a Counted strings package > for Ada. > > Fixed strings are great in terms of performance. Bounded strings are > pretty good. However I havent seen anyone do a performance analysis of > Counted strings. I'm thinking in the Forth sense of the type. > > i.e. The first element of the String is a number indicating the length of > the string. No null terminators needed. > A bit more flexible than Fixed strings, a heck of a lot faster than Null > terminated strings. Not sure how they stack up to Bounded strings. > > Has anyone played with these in an Ada context? > > I'm gonna write my own experimental package if nobody else has > > Freejack -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jsf.mil/NSFrames.htm Send Replies To: m c o n d i c @ a c m . o r g "So if I understand 'The Matrix Reloaded' correctly, the Matrix is basically a Microsoft operating system - it runs for a while and then crashes and reboots. By design, no less. Neo is just a memory leak that's too hard to fix, so they left him in... The users don't complain because they're packed in slush and kept sedated" -- Marin D. Condic ======================================================================