// sets won't allow duplicates, so this addition is ok
set.add(value);
}
}
result = new BagAttribute(bags[0].getType(), set);
break;
// *-union takes two bags of the same type and returns a bag of
// that type
case ID_BASE_UNION:
// create a bag with all the elements from both inputs, removing
// all duplicate values
Iterator it0 = bags[0].iterator();
while (it0.hasNext()) {
// first off, add all elements from the first bag...the set
// will ignore all duplicates
set.add(it0.next());
}
Iterator it1 = bags[1].iterator();
while (it1.hasNext()) {
// now add all the elements from the second bag...again, all
// duplicates will be ignored by the set
set.add(it1.next());
}
result = new BagAttribute(bags[0].getType(), set);
break;
}
return new EvaluationResult(result);