comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <nobody@noplace.com>
Subject: Re: Strings Fixed, Bounded, and Counted. Performance Inquiry.
Date: Fri, 24 Oct 2003 20:28:40 GMT
Date: 2003-10-24T20:28:40+00:00	[thread overview]
Message-ID: <3F998B6D.8040305@noplace.com> (raw)
In-Reply-To: pan.2003.10.24.20.24.13.318562.974@nospam.net

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
======================================================================




  reply	other threads:[~2003-10-24 20:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-24 20:18 Strings Fixed, Bounded, and Counted. Performance Inquiry Freejack
2003-10-24 20:28 ` Marin David Condic [this message]
2003-10-25  0:46 ` Jeffrey Carter
2003-10-25 21:24   ` Marin David Condic
2003-10-27 17:18 ` Stephen Leake
2003-10-27 19:15   ` Freejack
2003-10-27 19:31     ` Stephen Leake
2003-11-02 10:42   ` Tarjei T. Jensen
replies disabled

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