🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to deal with Sets

#12153
From: nicolasr
Date: Tue, 23 Dec 2003 21:07
47 lines
1899 bytes
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
>
Technical Details
Message-ID: <3fe8af1b@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>

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
From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fe8a95e@newsgroups.borland.com>
Subject: Re: How to deal with Sets
Date: Tue, 23 Dec 2003 22:07:22 +0100
Lines: 49
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 80.133.160.153
Message-ID: <3fe8af1b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1072213787 80.133.160.153 (23 Dec 2003 13:09:47 -0700)
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