Language:
C++ sets class Download

Details Screenshots Publisher Information Download

Download C++ sets class


The sets class can be used to perform set operations in your programs. It represents set elements as bits in a private array of unsigned long integers. The array size is a defined constant which can be changed to suit your application.<br /><br />The sets class supports the following set operations by means of C++ operator overloading:<br /><br />union<br />The union of two sets A, B is the set of all elements which belong to either A or B. In the sets class, the symbol + is the binary union operator: <br />A + B = {x: x is in A -or- x is in B }<br /><br />intersection<br />The intersection of two sets A, B is the set of all elements which belong to both A and B. The symbol * is the binary intersection operator:<br />A * B = {x: x is in A -and- x is in B }<br />example<br />Let A = {1, 2, 3, 4} and B = {3, 4, 5, 6}. Then<br />A + B = {1, 2, 3, 4, 5, 6}<br />A * B = {3, 4}<br /><br />complement<br />In set theory, sets are subsets of a fixed universal set U. In the sets class, U is the set of elements numbered from 1 to MAX_WORDS * WORD_SIZE. In the class declaration file below, the following definitions are made:<br />#define MAX_WORDS 2<br />#define WORD_SIZE ( 8 * sizeof( unsigned long ) )<br />These parameters make the range of U, 1 to 64 in sets. To increase or decrease the size of U, change the defined value of MAX_WORDS.<br /><br />The complement of set A is the set of elements belonging to U but not belonging to A. The symbol ~ is the unary complement operator:<br />~A = {x: x is in U, x is not in A }<br />example<br />Let A = {1, 2, 3, 4} and B = {3, 4, 5, 6}. Then<br />~A = {5, 6, 7, . . .}<br />~B = {1, 2, 7, 8, 9, . . .}<br /><br />difference<br />The difference of two sets A, B is the set of all elements which belong to A less those in B. The symbol - is the binary difference operator:<br />A - B = {x: x is in A, x is not in B}<br />example<br />Let A = {1, 2, 3, 4} and B = {3, 4, 5, 6}. Then<br />A - B = {1, 2}<br />It can be shown that A - B = A * ~B.<br /><br />symmetric difference<br />The symmetric difference of two sets A, B is the set of all elements which belong t...

File Size: 0.014 MB

Download C++ sets class at:

0 downloads

Previous Listing | Next Listing