Changeset View
Changeset View
Standalone View
Standalone View
src/EvtGenBase/EvtIdSet.cpp
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | int EvtIdSet::contains( const std::string nm ) const | ||||
return 0; | return 0; | ||||
} | } | ||||
void EvtIdSet::append( const EvtIdSet set1 ) | void EvtIdSet::append( const EvtIdSet set1 ) | ||||
{ | { | ||||
int combLen = _numInList + set1.sizeOfSet(); | int combLen = _numInList + set1.sizeOfSet(); | ||||
int uniqueLen = 0; | int uniqueLen = 0; | ||||
EvtId* combSet; | EvtId* combSet = new EvtId[combLen]; | ||||
combSet = new EvtId[combLen]; | |||||
int i; | int i; | ||||
for ( i = 0; i < combLen; i++ ) { | for ( i = 0; i < combLen; i++ ) { | ||||
if ( i >= _numInList ) { | if ( i >= _numInList ) { | ||||
//check that there are no overlaps between lists | //check that there are no overlaps between lists | ||||
int j; | int j; | ||||
int isUnique = 1; | int isUnique = 1; | ||||
for ( j = 0; j < _numInList; j++ ) { | for ( j = 0; j < _numInList; j++ ) { | ||||
if ( _list[j] == set1.getElem( i - _numInList ) ) { | if ( _list[j] == set1.getElem( i - _numInList ) ) { | ||||
isUnique = 0; | isUnique = 0; | ||||
} | } | ||||
} | } | ||||
if ( isUnique == 1 ) { | if ( isUnique == 1 ) { | ||||
combSet[uniqueLen] = set1.getElem( i - _numInList ); | combSet[uniqueLen] = set1.getElem( i - _numInList ); | ||||
uniqueLen += 1; | uniqueLen += 1; | ||||
} | } | ||||
} else { | } else { | ||||
combSet[uniqueLen] = _list[i]; | combSet[uniqueLen] = _list[i]; | ||||
uniqueLen += 1; | uniqueLen += 1; | ||||
} | } | ||||
} | |||||
delete _list; | delete[] _list; | ||||
_list = new EvtId[uniqueLen]; | _list = new EvtId[uniqueLen]; | ||||
_numInList = uniqueLen; | _numInList = uniqueLen; | ||||
for ( i = 0; i < _numInList; i++ ) { | for ( i = 0; i < _numInList; i++ ) { | ||||
_list[i] = combSet[i]; | _list[i] = combSet[i]; | ||||
} | } | ||||
delete combSet; | delete[] combSet; | ||||
} | |||||
} | } | ||||
int EvtIdSet::sizeOfSet() const | int EvtIdSet::sizeOfSet() const | ||||
{ | { | ||||
return _numInList; | return _numInList; | ||||
} | } | ||||
EvtId EvtIdSet::getElem( const int i ) const | EvtId EvtIdSet::getElem( const int i ) const | ||||
{ | { | ||||
return _list[i]; | return _list[i]; | ||||
} | } |