3D PLM Enterprise Architecture |
Middleware Abstraction |
Using SetsCreating and managing sets of CATString instances |
Use Case |
AbstractThis article shows how to create and manage a set of CATString instances. |
This use case is intended to show you how to create and manage a set of CATString instances.
[Top]
CAASysCollections is a set of use cases of the CAASystem.edu framework that illustrates the collection management capabilities.
[Top]
This use case shows summarizes the collection management capabilities:
This article describes the set of CATString instance capabilities. Note that the set of CATUnicodeString offers the same capabilities.
[Top]
To launch CAASysCollections, you will need to set up the build time environment, then compile CAASysCollections along with its prerequisites, set up the run time environment, and then execute the use case [1].
[Top]
The CAASysCollections use case is made of a several classes located in the CAASysCollections.m module of the CAASystem.edu framework:
Windows | InstallRootDirectory\CAASystem.edu\CAASysCollections.m\ |
Unix | InstallRootDirectory/CAASystem.edu/CAASysCollections.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
The following capabilities offered by lists of integers are described in the following steps:
# |
Step |
---|---|
1 | Create and fill in a set |
2 | Count the items |
3 | Insert items |
4 | Access items |
5 | Copy items from/to an array |
6 | Apply basic operators |
[Top]
A set of CATString instances is itself an instance of the CATSetOfCATString class.
void CAASetsSample() { CATSetOfCATString set1; set1.Add( CATString("A") ); set1.Add( CATString("B") ); set1.Add( CATString("D") ); ... |
The Add
method adds CATString instances to the set.
[Top]
... cout << "set1.Size() = " << set1.Size() << endl; ... |
The Size
method returns the number of items in the set. This
code provides the following output:
set1.Size() = 3 |
[Top]
... // A, B, D set1.Add( CATString("A")); // A, B, D set1.Add( CATString("C")); // A, B, C, D ... |
The Add
method adds items to the set. Note that no duplicate
items can exist in a set. As a consequence, the first call to Add
has no effect, since an item containing "A" already exists in the set.
The second call to Add
adds "C" to the set. This
character string is not appended to the set, but inserted using the alphabetical
order.
[Top]
... cout << "set1[2] = " << set1[2].CastToCharPtr() << endl; ... |
A given item in the set can be used by means of its rank in the set as if it where in an array. Note that the rank begins with 1. This code provides the following output:
set1[2] = B |
[Top]
... CATString *iArray = new CATString[4]; iArray[0] = "B"; iArray[1] = "C"; iArray[2] = "D"; iArray[3] = "E"; CATSetOfCATString set2(iArray, 4); CATString *ioArray = new CATString[set1.Size()]; set1.Array(ioArray); ... |
An array of CATString can be used as input for a set of CATString
instances. The second parameter is the number of items to copy from the array.
Conversely, a set of CATString instances can be used a input to create an
array. The Size
method is used to set the array size. The Array
method fills the array from the set.
[Top]
... CATSetOfCATString set3(set1); set3.Add(set2); CATSetOfCATString set4; CATSetOfCATString::Intersection(set1, set2, set4); CATSetOfCATString set5(set1); set5.Remove(set2); ... |
The Add
method can also take a set as parameter to merge two
sets. The following table shows the input sets and the result. Note that the set
does include duplicates, and that the items are arranged using the alphabetical
order.
set2 | B, C, D, E |
set3 | A, B, C, D |
resulting set3 | A, B, C, D, E |
The Intersection
static method performs the intersection of set1
with set2, and puts the result in set 4. The following table shows the input
sets and the result.
set1 | A, B, C, D |
set2 | B, C, D, E |
set4 | B, C, D |
The Remove
method takes a set as parameter to subtract it from
the set to which the method applies. The following table shows the input sets
and the result.
set5 | A, B, C, D |
set2 | B, C, D, E |
resulting set5 | A |
[Top]
This use case shows how to create and use a set of CATString instances. The same capabilities apply to a set of CATUnicodeString instances.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Mar 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.