🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12156

Re: How to deal with Sets

#12156
From: Muzzy
Date: Tue, 23 Dec 2003 21:26
52 lines
2208 bytes
nicolasr wrote:

> Hi,
> C++Builder has a C++ template class named 'Set' to
> emulate the Delphi set.
> Look the help for 'Set'.
> 
> Here is an example:
> 
> //define a special Set for upper case  chars
> typedef Set<char, 'A', 'Z'> CharSet;
> 
> CharSet mySet;
> //mySet initially empty, fill with values
> mySet << 'A' << 'B' << 'C' ...
> 
> char c = 'C'; //test
> 
> //this corresponds to Delphis 'in'
> if(mySet.Contains(c))
>    ShowMessage("Contains c");
> 
> 
> Your code looks like you would never have to change
> the set, though. In this case I would simply compare
> against the upper and lower bound:
> 
> if(c > 'A' && c < 'Z')
>    ShowMessage("Between A and Z");
> 
> regards,
> Nick
> 
> 
>>Hi,
>>
>>Quick question, but i just can't find an answer:
>>i am tarnslating a program from Delphi to C++ Builder and so question is
>>how to translate to c++ such pascal statemet:
>>
>>Var c : char;
>>...
>>If c in ['A'..'Z'] Then ...
>>
>>Of cource i just need ".. c in ['A'..'Z'].. ", because i couldn't find
>>how to work with sets in C++.
>>
>>Thank you,
>>Andrey
>>

Thank you guys! I should've thought about plain comparison  'A'<=c<='Z'.
Technical Details
Message-ID: <3fe8b32b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fe8a95e@newsgroups.borland.com> <3fe8af1b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,4cc169f4a0bbe667
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-23 13:39:49 PST
Date: Tue, 23 Dec 2003 16:26:07 -0500
From: Muzzy <leyandrew@yahoo.com>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How to deal with Sets
References: <3fe8a95e@newsgroups.borland.com> <3fe8af1b@newsgroups.borland.com>
In-Reply-To: <3fe8af1b@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.91.233.60
Message-ID: <3fe8b32b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1072214827 24.91.233.60 (23 Dec 2003 13:27:07 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail