Skip to main content
PREV CLASS NEXT CLASS FRAMES NO FRAMES

 

Class IloTupleSet

IloDiscreteDataCollection
   |
   +--IloTupleSet
Example:
tuple T {
  int i;
  string s;
}
{T} 1;
{T} tupleset2;

execute {
  tupleset1.add(1, "one");
  tupleset1.add(2, "two");
  tupleset2.add(tupleset1.get(1,"one"));
}

execute{
  writeln("tupleset1 = ",tupleset1," and tupleset1.size = ",tupleset1.size);
  writeln("tupleset2 = ",tupleset2," and tupleset2.size = ",tupleset2.size);  
}
After execution, the Scripting log shows:
tupleset1 =  {<1 "one"> <2 "two">} and tupleset1.size = 2
tupleset2 =  {<1 "one">} and tupleset2.size = 1
Iterating properties:
Iterates on the tuples in this set.
Index resolution:
Default behavior.
Available for:
all
OPL type:
{T} , where T is a declared tuple type

Properties inherited from class IloDiscreteDataCollection
size
Method Summary
Method Attributes Method Name and Description
all
add(componentValue, componentValueN)
Adds a new tuple with the given component values.
all
addOnly(componentValue, componentValueN)
Adds a new tuple with the given component values, without returning the tuple.
all
clear()
Removes all tuples from the set.
all
find(componentValue, componentValueN)
Finds the tuple with the component values you pass as parameters.
all
get(componentValue, componentValueN)
Gets the tuple with the component values you pass as parameters.
all
Returns the name of the field at position i.
all
Returns the number of fields of the tuple of this set.
all
importSet(tSet)
Adds an external tupleset.
all
remove(componentValue, componentValueN)
Removes the tuple.
Methods inherited from class IloDiscreteDataCollection
addAll, contains, end, isOrdered, isReversed, isSorted
Method Detail
add
{IloTuple} add(componentValue, componentValueN)
Adds a new tuple with the given component values.

The values are passed in the order of declaration of the tuple type.

If the tuple already exists, the method returns the existing tuple.

If the set is sorted, all previous instances of tuples will be invalidated.

The fastest method to populate a set is to use addOnly().

Parameters:
componentValue - The value for the first tuple component.
componentValueN - The value for the n-th tuple component.
Returns:
The tuple with the given component values or the already existing tuple.
Available for:
all

addOnly
addOnly(componentValue, componentValueN)
Adds a new tuple with the given component values, without returning the tuple.

The values are passed in the order of declaration of the tuple type.

This method is faster than add() and uses less memory as it returns nothing.

Parameters:
componentValue - The value for the first tuple component.
componentValueN - The value for the n-th tuple component.
Returns:
Nothing.
Available for:
all

clear
clear()
Removes all tuples from the set.
Returns:
Nothing.
Available for:
all

find
{IloTuple} find(componentValue, componentValueN)
Finds the tuple with the component values you pass as parameters.

You can pass all the components or all the key components, in the order of declaration of the tuple type.

If no tuple exists, the value null is returned.

Parameters:
componentValue - The value for the first tuple component or key component.
componentValueN - The value for the n-th tuple component or key component.
Returns:
The tuple with the given component values, or null.
Available for:
all

get
{IloTuple} get(componentValue, componentValueN)
Gets the tuple with the component values you pass as parameters.

You can pass all the components or all the key components, in the order of declaration of the tuple type.

If no tuple exists, a runtime error is raised.

Parameters:
componentValue - The value for the first tuple component or key component.
componentValueN - The value for the n-th tuple component or key component.
Returns:
The tuple with the given component values, or raises an error.
Available for:
all

getFieldName
{string} getFieldName(i)
Returns the name of the field at position i.
Parameters:
i
Example:
writeln("Tuple:");
for (var i =0; i < ts.getNFields(); i++) {
  var f = ts.getFieldName(i);  
  writeln("  field name: ", f );
}
Returns:
The field name.
Available for:
all

getNFields
{int} getNFields()
Returns the number of fields of the tuple of this set.
Returns:
The number of fields.
Available for:
all

importSet
importSet(tSet)
Adds an external tupleset.
Parameters:
tSet - The tupleSet to add to the current one.
Returns:
Nothing.
Available for:
all

remove
remove(componentValue, componentValueN)
Removes the tuple. Does nothing if the expected item does not exist.
Parameters:
componentValue - The value for the first tuple component.
componentValueN - The value for the n-th tuple component.
Available for:
all

©Copyright IBM Corp. 1987-2011.