Re: String filtering
- From: David Trudgett <wpower@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Sep 2005 11:29:19 +1000
"Jeffrey R. Carter" <spam@xxxxxxxx> writes:
> David Trudgett wrote:
>
> It seems odd to do this:
>
>> New_Str : Unbounded_String
>> := To_Unbounded_String(Count(Str, Alphanumeric_Set));
>
> if you're also going to do this:
>
>> New_Str := To_Unbounded_String("");
>
>> Append(New_Str, Element(Str, Char));
>
> If you allocate the expected length (and not overwrite that with a
> null string), then you can use Replace_Element.
Yes, it does seem odd. As it happens, the code is easier and shorter
that way, but <<New_Str := To_Unbounded_String("");>> might free
storage in some implementations, so I created a new version using
Replace_Element instead.
>
> Is there some reason you're not doing this in place, using Delete?
Repeated deletes would cause a lot of copying (though not a problem
for my particular purposes at present).
Now, go away or I shall taunt you a second time! ;-)
David
P.S. Thanks everyone for your comments on this one. Stay tuned for the
next exciting function call! :-)
--
David Trudgett
http://www.zeta.org.au/~wpower/
"While the popular understanding of anarchism is of a violent,
anti-State movement, anarchism is a much more subtle and nuanced
tradition than a simple opposition to government power. Anarchists
oppose the idea that power and domination are necessary for society,
and instead advocate more co-operative, anti-hierarchical forms of
social, political and economic organisation."
-- The Politics of Individualism, p. 106
.
- Follow-Ups:
- Re: String filtering
- From: Jeffrey R. Carter
- Re: String filtering
- References:
- String filtering
- From: David Trudgett
- Re: String filtering
- From: David Trudgett
- Re: String filtering
- From: Jeffrey R. Carter
- String filtering
- Prev by Date: Re: String filtering
- Next by Date: Re: String filtering
- Previous by thread: Re: String filtering
- Next by thread: Re: String filtering
- Index(es):