473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Set of values

In C++ Builder there was a construct called a Set, based on a an
enumeration, where more than one enumerated value could make up the set so
that any combination of enumerated values in an enum could be part of the
Set. It was implemented as a template, and was compatible with the built-in
Set of Object Pascal/Delphi. As an example:

enum SomeEnum
{
Value1,
Value2,
Value3
};

Set<SomeEnum,Value1,Value3> mySet;

and then one had operators/member functions to add, remove, and check
whether a given enumerated value was in the set.

Does the .NET framework have anything like this, which I can use in my MC++
modules and components in a CLS compliant way so that other .NET languages
can interoperate with my construct ?

The closest thing I can think of is a BitArray or BitVector32 class, but the
downside to this is specifying what each bit represents. I am not sure what
is the best CLS way to do the latter. Any information on this is welcome as
I am sure other .NET developers have faced the same problem.
Nov 16 '05 #1
3 1193
The C++ standard template library offers the container
you are looking for.

Try:

#include <set>

enum SomeEnum { Value1, Value2, Value3 };

int main()
{
std::set<enum SomeEnum> mySet;

mySet.insert( Value2 );
// Insert an element into the set.

if ( mySet.find( Value3 ) != mySet.end() ) {
// check if Value3 is in the set
-----Original Message-----
In C++ Builder there was a construct called a Set, based on a anenumeration, where more than one enumerated value could make up the set sothat any combination of enumerated values in an enum could be part of theSet. It was implemented as a template, and was compatible with the built-inSet of Object Pascal/Delphi. As an example:

enum SomeEnum
{
Value1,
Value2,
Value3
};

Set<SomeEnum,Value1,Value3> mySet;

and then one had operators/member functions to add, remove, and checkwhether a given enumerated value was in the set.

Does the .NET framework have anything like this, which I can use in my MC++modules and components in a CLS compliant way so that other .NET languagescan interoperate with my construct ?

The closest thing I can think of is a BitArray or BitVector32 class, but thedownside to this is specifying what each bit represents. I am not sure whatis the best CLS way to do the latter. Any information on this is welcome asI am sure other .NET developers have faced the same problem.

.

Nov 16 '05 #2
Sorry for the interrupted message before (too many
fingers on keyboard error). Here is the completed reply...

The C++ standard template library offers the container
you are looking for.

Try:

#include <iostream>
#include <set>

enum SomeEnum { Value1, Value2, Value3, Value4 };

int main()
{
std::set<enum SomeEnum> mySet;

std::cout << "mySet now contains " << mySet.size()
<< " elements.\n";

mySet.insert( Value1 );
mySet.insert( Value2 );
mySet.insert( Value3 );
// Insert some elements into the set.

std::cout << "mySet now contains " << mySet.size()
<< " elements.\n";

mySet.erase( Value3 );
// erase one of the elements.

std::cout << "mySet now contains " << mySet.size()
<< " elements.\n";

// check if some value is member of set.
if ( mySet.find( Value2 ) != mySet.end() ) {
std::cout << "Value2 is in set\n";
}
else {
std::cout << "Value2 is not in set\n";
}

// loop through all current members of the set
for ( std::set<enum SomeEnum>::const_iterator p =
mySet.begin(); p != mySet.end(); ++p )
{
std::cout << "Member: " << *p << "\n";
}

return 0;
}
-----Original Message-----
In C++ Builder there was a construct called a Set, based on a anenumeration, where more than one enumerated value could make up the set sothat any combination of enumerated values in an enum could be part of theSet. It was implemented as a template, and was compatible with the built-inSet of Object Pascal/Delphi. As an example:

enum SomeEnum
{
Value1,
Value2,
Value3
};

Set<SomeEnum,Value1,Value3> mySet;

and then one had operators/member functions to add, remove, and checkwhether a given enumerated value was in the set.

Does the .NET framework have anything like this, which I can use in my MC++modules and components in a CLS compliant way so that other .NET languagescan interoperate with my construct ?

The closest thing I can think of is a BitArray or BitVector32 class, but thedownside to this is specifying what each bit represents. I am not sure whatis the best CLS way to do the latter. Any information on this is welcome asI am sure other .NET developers have faced the same problem.

.

Nov 16 '05 #3
Michael Böhnisch wrote:
The C++ standard template library offers the container
you are looking for.

Try:

#include <set>

enum SomeEnum { Value1, Value2, Value3 };

int main()
{
std::set<enum SomeEnum> mySet;

mySet.insert( Value2 );
// Insert an element into the set.

if ( mySet.find( Value3 ) != mySet.end() ) {
// check if Value3 is in the set
Quite true, but it is clearly not CLS compliant unless I wrap it with a __gc
class, which is quite possible. Thanks !


-----Original Message-----
In C++ Builder there was a construct called a Set, based on a an
enumeration, where more than one enumerated value could make up the
set so that any combination of enumerated values in an enum could be
part of the Set. It was implemented as a template, and was
compatible with the built-in Set of Object Pascal/Delphi. As an
example:

enum SomeEnum
{
Value1,
Value2,
Value3
};

Set<SomeEnum,Value1,Value3> mySet;

and then one had operators/member functions to add, remove, and check
whether a given enumerated value was in the set.

Does the .NET framework have anything like this, which I can use in
my MC++ modules and components in a CLS compliant way so that other
.NET languages can interoperate with my construct ?

The closest thing I can think of is a BitArray or BitVector32 class,
but the downside to this is specifying what each bit represents. I
am not sure what is the best CLS way to do the latter. Any
information on this is welcome as I am sure other .NET developers
have faced the same problem.
.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
1
by: Sue Adams | last post by:
I have a form on an asp page and am trying to write the code to place the values of all checkboxes that have been selected, into an array. The checkbox values will be used in a dynamic sql statement...
5
by: James Baker | last post by:
I have a form that has a dropdown list that will cause a post to the same page when it's changed. The problem I'm running into is that all of the controls reset to their default values (obviously...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
4
by: Steve Hall | last post by:
Folks, My secnario involves two tables - ObservationRegister, and Person. ObservationRegister contains most of the "useful" fields, including the UserID of the person that raised the record, and...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
2
by: Hennie | last post by:
I apologise if this is a stupid question, but I would appreciated any help on this subject. I want to create a view (VIEW_1 in example below) where I take numeric values from a field in one...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
13
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! With VALUES you can do something like: SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER) which will give you: LETTER NUMBER ------ ------ A 1 B 2...
8
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.