Adds rdcasts where appropriate

This commit is contained in:
kelley
2015-11-29 17:52:27 -05:00
parent 1f1b8407ff
commit 5dbec2fe85
17 changed files with 85 additions and 76 deletions

View File

@@ -210,7 +210,7 @@ void setHydrogenCoords(ROMol *mol, unsigned int hydIdx, unsigned int heavyIdx) {
const Atom *tAtom = mol->getAtomWithIdx(*nbrIdx);
int cip = 0;
tAtom->getPropIfPresent<int>(common_properties::_CIPRank, cip);
nbrs.push_back(std::make_pair(cip, *nbrIdx));
nbrs.push_back(std::make_pair(cip, rdcast<int>(*nbrIdx)));
}
++nbrIdx;
}
@@ -611,7 +611,7 @@ void mergeQueryHs(RWMol &mol, bool mergeUnmappedOnly) {
Atom &bgn = *mol.getAtomWithIdx(*begin);
if (!mergeUnmappedOnly ||
!bgn.hasProp(common_properties::molAtomMapNumber)) {
atomsToRemove.push_back(*begin);
atomsToRemove.push_back(rdcast<unsigned int>(*begin));
++numHsToRemove;
}
}

View File

@@ -62,7 +62,7 @@ void pickFusedRings(int curr, const INT_INT_VECT_MAP &neighMap, INT_VECT &res,
bool checkFused(const INT_VECT &rids, INT_INT_VECT_MAP &ringNeighs) {
INT_INT_VECT_MAP_CI nci;
int nrings = ringNeighs.size();
int nrings = rdcast<int>(ringNeighs.size());
boost::dynamic_bitset<> done(nrings);
int rid;
INT_VECT fused;
@@ -87,7 +87,7 @@ bool checkFused(const INT_VECT &rids, INT_INT_VECT_MAP &ringNeighs) {
void makeRingNeighborMap(const VECT_INT_VECT &brings,
INT_INT_VECT_MAP &neighMap, unsigned int maxSize) {
int nrings = brings.size();
int nrings = rdcast<int>(brings.size());
int i, j;
INT_VECT ring1;
for (i = 0; i < nrings; i++) {
@@ -340,7 +340,7 @@ void applyHuckelToFused(
INT_VECT aromRings;
aromRings.resize(0);
unsigned int nrings = fused.size();
unsigned int nrings = rdcast<unsigned int>(fused.size());
INT_VECT curRs;
INT_VECT_CI mri;
curRs.push_back(fused.front());
@@ -350,7 +350,7 @@ void applyHuckelToFused(
pos = -1;
INT_VECT unionAtms;
Union(srings, unionAtms);
unsigned int nAtms = unionAtms.size();
unsigned int nAtms = rdcast<unsigned int>(unionAtms.size());
std::set<unsigned int> doneAtoms;
while (1) {
if (pos == -1) {
@@ -414,7 +414,7 @@ void applyHuckelToFused(
}
} // end check huckel rule
} // end while(1)
narom += aromRings.size();
narom += rdcast<int>(aromRings.size());
}
bool isAtomCandForArom(const Atom *at, const ElectronDonorType edon) {
@@ -691,7 +691,7 @@ int setAromaticity(RWMol &mol) {
// huckel rule - of course paying attention to fused systems.
INT_VECT doneRs;
int curr = 0;
int cnrs = cRings.size();
int cnrs = rdcast<int>(cRings.size());
boost::dynamic_bitset<> fusDone(cnrs);
INT_VECT fused;
while (curr < cnrs) {

View File

@@ -578,7 +578,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx,
seenFromHere.set(atomIdx);
molStack.push_back(MolStackElem(atom));
atomOrders[atom->getIdx()] = molStack.size();
atomOrders[atom->getIdx()] = rdcast<int>(molStack.size());
colors[atomIdx] = GREY_NODE;
INT_LIST travList;
@@ -601,7 +601,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx,
// this is end of the ring closure
// we can just pull the ring index from the bond itself:
molStack.push_back(MolStackElem(bond, atomIdx));
bondVisitOrders[bIdx] = molStack.size();
bondVisitOrders[bIdx] = rdcast<int>(molStack.size());
molStack.push_back(MolStackElem(ringIdx));
// don't make the ring digit immediately available again: we don't want
// to have the same
@@ -616,7 +616,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx,
throw ValueErrorException(
"Too many rings open at once. SMILES cannot be generated.");
}
unsigned int lowestRingIdx = cAIt - cyclesAvailable.begin();
unsigned int lowestRingIdx = rdcast<unsigned int>(cAIt - cyclesAvailable.begin());
cyclesAvailable[lowestRingIdx] = 0;
++lowestRingIdx;
bond->setProp(common_properties::_TraversalRingClosureBond,
@@ -710,16 +710,16 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx,
travList.push_back(bond->getIdx());
if (possiblesIt + 1 != possibles.end()) {
// we're branching
molStack.push_back(MolStackElem("(", possiblesIt - possibles.begin()));
molStack.push_back(MolStackElem("(", rdcast<int>(possiblesIt - possibles.begin())));
}
molStack.push_back(MolStackElem(bond, atomIdx));
bondVisitOrders[bond->getIdx()] = molStack.size();
bondVisitOrders[bond->getIdx()] = rdcast<int>(molStack.size());
dfsBuildStack(mol, possibleIdx, bond->getIdx(), colors, cycles, ranks,
cyclesAvailable, molStack, atomOrders, bondVisitOrders,
atomRingClosures, atomTraversalBondOrder, bondsInPlay,
bondSymbols);
if (possiblesIt + 1 != possibles.end()) {
molStack.push_back(MolStackElem(")", possiblesIt - possibles.begin()));
molStack.push_back(MolStackElem(")", rdcast<int>(possiblesIt - possibles.begin())));
}
}

View File

@@ -238,7 +238,7 @@ void iterateCIPRanks(const ROMol &mol, DOUBLE_VECT &invars, UINT_VECT &ranks,
cipEntries[*it].insert(cipEntries[*it].end(), localEntry.rbegin(),
localEntry.rend());
if (cipEntries[*it].size() > longestEntry) {
longestEntry = cipEntries[*it].size();
longestEntry = rdcast<unsigned int>(cipEntries[*it].size());
}
}
// ----------------------------------------------------
@@ -246,7 +246,7 @@ void iterateCIPRanks(const ROMol &mol, DOUBLE_VECT &invars, UINT_VECT &ranks,
// pad the entries so that we compare rounds to themselves:
//
for (INT_LIST_I it = allIndices.begin(); it != allIndices.end(); ++it) {
unsigned int sz = cipEntries[*it].size();
unsigned int sz = rdcast<unsigned int>(cipEntries[*it].size());
if (sz < longestEntry) {
cipEntries[*it].insert(cipEntries[*it].end(), longestEntry - sz, -1);
}

View File

@@ -38,7 +38,7 @@ boost::uint32_t computeRingInvariant(INT_VECT ring, unsigned int nAtoms) {
void convertToBonds(const VECT_INT_VECT &res, VECT_INT_VECT &brings,
const ROMol &mol) {
for (VECT_INT_VECT_CI ri = res.begin(); ri != res.end(); ++ri) {
unsigned int rsiz = ri->size();
unsigned int rsiz = rdcast<unsigned int>(ri->size());
INT_VECT bring(rsiz);
for (unsigned int i = 0; i < (rsiz - 1); i++) {
const Bond *bnd = mol.getBondBetweenAtoms((*ri)[i], (*ri)[i + 1]);
@@ -171,7 +171,7 @@ void findSSSRforDupCands(const ROMol &mol, VECT_INT_VECT &res,
for (VECT_INT_VECT_CI sri = srings.begin(); sri != srings.end();
++sri) {
if (sri->size() < minSiz) {
minSiz = sri->size();
minSiz = rdcast<unsigned int>(sri->size());
}
nrings.push_back((*sri));
}
@@ -261,7 +261,7 @@ void removeExtraRings(VECT_INT_VECT &res, unsigned int nexpt,
j < res.size() && bitBrings[j].count() == bitBrings[i].count();
++j) {
if (!consider[j] || !availRings[j]) continue;
int overlap = (bitBrings[j] & munion).count();
int overlap = rdcast<int>((bitBrings[j] & munion).count());
if (overlap > bestOverlap) {
bestOverlap = overlap;
bestJ = j;
@@ -710,18 +710,18 @@ int smallestRingsBfs(const ROMol &mol, int root, VECT_INT_VECT &rings,
ring.insert(ring.end(), npath.begin(), npath.end());
#endif
if (ring.size() <= curSize) {
curSize = ring.size();
curSize = rdcast<unsigned int>(ring.size());
rings.push_back(ring);
} else {
// we are done with the smallest rings
return rings.size();
return rdcast<unsigned int>(rings.size());
}
} // end of found a ring
} // end of we have seen this neighbor before
} // end of nbrIdx not part of current path and not a done atom
} // end of loop over neighbors of current atom
} // moving to the next node
return rings.size(); // if we are here we should have found everything around
return rdcast<unsigned int>(rings.size()); // if we are here we should have found everything around
// the node
}
@@ -745,7 +745,7 @@ bool _atomSearchBFS(const ROMol &tMol, unsigned int startAtomIdx,
while (nbrIdx != endNbrs) {
if (*nbrIdx == endAtomIdx) {
if (currAtomIdx != startAtomIdx) {
tv.push_back(*nbrIdx);
tv.push_back(rdcast<unsigned int>(*nbrIdx));
// make sure the ring we just found isn't already in our set
// of rings (this was an extension of sf.net issue 249)
boost::uint32_t invr =
@@ -763,7 +763,7 @@ bool _atomSearchBFS(const ROMol &tMol, unsigned int startAtomIdx,
std::find(tv.begin(), tv.end(), *nbrIdx) == tv.end()) {
//} else if(ringAtoms[*nbrIdx]){
INT_VECT nv(tv);
nv.push_back(*nbrIdx);
nv.push_back(rdcast<unsigned int>(*nbrIdx));
bfsq.push_back(nv);
}
++nbrIdx;
@@ -828,7 +828,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) {
// check if SSSR's are already on the molecule
if (mol.getRingInfo()->isInitialized()) {
res = mol.getRingInfo()->atomRings();
return res.size();
return rdcast<int>(res.size());
} else {
mol.getRingInfo()->initialize();
}
@@ -985,8 +985,8 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) {
std::cerr<<std::endl;
}
#endif
int nexpt = (nbnds - curFrag.size() + 1);
int ssiz = fragRes.size();
int nexpt = rdcast<int>((nbnds - curFrag.size() + 1));
int ssiz = rdcast<int>(fragRes.size());
// first check that we got at least the number of expected rings
// std::cerr<<"EXPT: "<<ssiz<<" "<<nexpt<<std::endl;
@@ -1025,7 +1025,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) {
}
}
}
ssiz = fragRes.size();
ssiz = rdcast<int>(fragRes.size());
if (ssiz < nexpt) {
throw ValueErrorException("could not find number of expected rings.");
}
@@ -1058,7 +1058,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) {
// update the ring memberships of atoms and bonds in the molecule:
// store the SSSR rings on the the molecule as a property
// we will ignore any existing SSSRs ont eh molecule - simply overwrite
return res.size();
return rdcast<int>(res.size());
}
int symmetrizeSSSR(ROMol &mol) {
@@ -1079,7 +1079,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) {
nsssr = findSSSR(mol, sssrs);
} else {
sssrs = mol.getRingInfo()->atomRings();
nsssr = sssrs.size();
nsssr = rdcast<unsigned int>(sssrs.size());
}
VECT_INT_VECT_CI srci;
@@ -1092,7 +1092,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) {
// now check if there are any extra rings on the molecule
if (!mol.hasProp(common_properties::extraRings)) {
// no extra rings nothign to be done
return res.size();
return rdcast<int>(res.size());
}
const VECT_INT_VECT &extras =
mol.getProp<VECT_INT_VECT>(common_properties::extraRings);
@@ -1107,7 +1107,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) {
INT_VECT sr, exr;
INT_VECT_CI eri;
unsigned int eid, srid, ssiz;
unsigned int next = bextra.size();
unsigned int next = rdcast<unsigned int>(bextra.size());
// now the trick is the following
// we will replace each ring of size ssiz from the SSSR with
// one of the same size rings in the extras. Compute the union of of the new
@@ -1124,7 +1124,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) {
std::cerr<<std::endl;
std::cerr<<"------"<<std::endl;
#endif
ssiz = sr.size();
ssiz = rdcast<unsigned int>(sr.size());
INT_VECT exrid;
exrid.push_back(srid);
Union(bsrs, nunion, &exrid);
@@ -1175,7 +1175,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) {
if (mol.hasProp(common_properties::extraRings)) {
mol.clearProp(common_properties::extraRings);
}
return res.size();
return rdcast<int>(res.size());
}
namespace {

View File

@@ -271,7 +271,7 @@ bool kekulizeWorker(RWMol &mol, const INT_VECT &allAtms,
// if the neighbor is not on the stack add it
if (std::find(astack.begin(), astack.end(),
static_cast<int>(*nbrIdx)) == astack.end()) {
astack.push_back(*nbrIdx);
astack.push_back(rdcast<int>(*nbrIdx));
}
// check if the neighbor is also a candidate for a double bond
@@ -287,7 +287,7 @@ bool kekulizeWorker(RWMol &mol, const INT_VECT &allAtms,
(mol.getBondBetweenAtoms(curr, *nbrIdx)->getIsAromatic() ||
mol.getAtomWithIdx(curr)->getAtomicNum() == 0 ||
mol.getAtomWithIdx(*nbrIdx)->getAtomicNum() == 0)) {
opts.push_back(*nbrIdx);
opts.push_back(rdcast<int>(*nbrIdx));
} // end of curr atoms can have a double bond
++nbrIdx;
} // end of looping over neighbors
@@ -519,7 +519,7 @@ void Kekulize(RWMol &mol, bool markAtomsBonds, unsigned int maxBackTracks) {
RingUtils::makeRingNeighborMap(brings, neighMap);
int curr = 0;
int cnrs = arings.size();
int cnrs = rdcast<int>(arings.size());
boost::dynamic_bitset<> fusDone(cnrs);
while (curr < cnrs) {
INT_VECT fused;

View File

@@ -234,7 +234,7 @@ double *getDistanceMat(const ROMol &mol, bool useBO, bool useAtomWts,
double *getDistanceMat(const ROMol &mol, const std::vector<int> &activeAtoms,
const std::vector<const Bond *> &bonds, bool useBO,
bool useAtomWts) {
const int nAts = activeAtoms.size();
const int nAts = rdcast<int>(activeAtoms.size());
double *dMat = new double[nAts * nAts];
int i, j;
@@ -245,12 +245,12 @@ double *getDistanceMat(const ROMol &mol, const std::vector<int> &activeAtoms,
for (std::vector<const Bond *>::const_iterator bi = bonds.begin();
bi != bonds.end(); bi++) {
const Bond *bond = *bi;
i = std::find(activeAtoms.begin(), activeAtoms.end(),
i = rdcast<int>(std::find(activeAtoms.begin(), activeAtoms.end(),
static_cast<int>(bond->getBeginAtomIdx())) -
activeAtoms.begin();
j = std::find(activeAtoms.begin(), activeAtoms.end(),
activeAtoms.begin());
j = rdcast<int>(std::find(activeAtoms.begin(), activeAtoms.end(),
static_cast<int>(bond->getEndAtomIdx())) -
activeAtoms.begin();
activeAtoms.begin());
double contrib;
if (useBO) {
if (!bond->getIsAromatic()) {
@@ -358,7 +358,7 @@ INT_LIST getShortestPath(const ROMol &mol, int aid1, int aid2) {
done = true;
break;
}
bfsQ.push_back(*nbrIdx);
bfsQ.push_back(rdcast<int>(*nbrIdx));
}
nbrIdx++;
}

View File

@@ -93,8 +93,8 @@ double computeBalabanJ(const ROMol &mol, bool useBO, bool force,
}
beg++;
}
nb = bondPath->size();
nAts = atomsInPath.size();
nb = rdcast<int>(bondPath->size());
nAts = rdcast<int>(atomsInPath.size());
dMat = MolOps::getDistanceMat(mol, atomsInPath, bonds, true, true);
res = computeBalabanJ(dMat, nb, nAts);
delete[] dMat;

View File

@@ -524,7 +524,7 @@ unsigned int getMolFrags(const ROMol &mol, VECT_INT_VECT &frags) {
for (INT_INT_VECT_MAP_CI mci = comMap.begin(); mci != comMap.end(); mci++) {
frags.push_back((*mci).second);
}
return frags.size();
return rdcast<unsigned int>(frags.size());
}
template <typename T>

View File

@@ -29,7 +29,7 @@ const int32_t MolPickler::versionPatch = 0;
const int32_t MolPickler::endianId = 0xDEADBEEF;
void streamWrite(std::ostream &ss, const std::string &what) {
unsigned int l = what.length();
unsigned int l = rdcast<unsigned int>(what.length());
ss.write((const char *)&l, sizeof(l));
ss.write(what.c_str(), sizeof(char) * l);
};
@@ -145,7 +145,7 @@ void pickleQuery(std::ostream &ss, const Query<int, T const *, true> *query) {
boost::tie(lowerOpen, upperOpen) =
static_cast<const RangeQuery<int, T const *, true> *>(query)
->getEndsOpen();
ends = 0 | (lowerOpen << 1) | upperOpen;
ends = 0 | (rdcast<int>(lowerOpen) << 1) | rdcast<int>(upperOpen);
streamWrite(ss, ends);
} else if (typeid(*query) == typeid(SetQuery<int, T const *, true>)) {
streamWrite(ss, MolPickler::QUERY_SET);
@@ -934,12 +934,12 @@ bool getAtomMapNumber(const Atom *atom, int &mapNum) {
int tmpInt;
try {
atom->getProp(common_properties::molAtomMapNumber, tmpInt);
} catch (boost::bad_any_cast &exc) {
} catch (boost::bad_any_cast &) {
const std::string &tmpSVal =
atom->getProp<std::string>(common_properties::molAtomMapNumber);
try {
tmpInt = boost::lexical_cast<int>(tmpSVal);
} catch (boost::bad_lexical_cast &lexc) {
} catch (boost::bad_lexical_cast &) {
res = false;
}
}
@@ -1264,7 +1264,7 @@ Atom *MolPickler::_addAtomFromPickle(std::istream &ss, ROMol *mol,
if (version > 5000) {
if (version < 6020) {
unsigned int sPos = ss.tellg();
unsigned int sPos = rdcast<unsigned int>(ss.tellg());
Tags tag;
streamRead(ss, tag, version);
if (tag == ATOM_MAPNUMBER) {
@@ -1356,7 +1356,7 @@ void MolPickler::_pickleBond(std::ostream &ss, const Bond *bond,
tmpChar = static_cast<char>(bond->getStereo());
streamWrite(ss, tmpChar);
const INT_VECT &stereoAts = bond->getStereoAtoms();
tmpChar = stereoAts.size();
tmpChar = rdcast<unsigned int>(stereoAts.size());
streamWrite(ss, tmpChar);
for (INT_VECT_CI idxIt = stereoAts.begin(); idxIt != stereoAts.end();
++idxIt) {

View File

@@ -126,13 +126,13 @@ void ROMol::initMol() {
}
unsigned int ROMol::getAtomDegree(const Atom *at) const {
return (boost::out_degree(at->getIdx(), d_graph));
return rdcast<unsigned int>(boost::out_degree(at->getIdx(), d_graph));
};
unsigned int ROMol::getAtomDegree(Atom::ATOM_SPTR at) const {
return getAtomDegree(at.get());
};
unsigned int ROMol::getNumAtoms(bool onlyExplicit) const {
int res = boost::num_vertices(d_graph);
int res = rdcast<int>(boost::num_vertices(d_graph));
if (!onlyExplicit) {
// if we are interested in hydrogens as well add them up from
// each
@@ -238,7 +238,7 @@ void ROMol::clearBondBookmark(const int mark, const Bond *bond) {
unsigned int ROMol::getNumBonds(bool onlyHeavy) const {
// By default resturn the bonds that connect only the heavy atoms
// hydrogen connecting bonds are ignores
int res = boost::num_edges(d_graph);
int res = rdcast<int>(boost::num_edges(d_graph));
if (!onlyHeavy) {
// If we need hydrogen connecting bonds add them up
for (ConstAtomIterator ai = beginAtoms(); ai != endAtoms(); ++ai) {
@@ -340,7 +340,7 @@ unsigned int ROMol::addAtom(Atom *atom_pin, bool updateLabel,
cfi != this->endConformers(); ++cfi) {
(*cfi)->setAtomPos(which, RDGeom::Point3D(0.0, 0.0, 0.0));
}
return which;
return rdcast<unsigned int>(which);
};
unsigned int ROMol::addAtom(Atom::ATOM_SPTR atom_sp, bool updateLabel) {
return addAtom(atom_sp.get(), updateLabel, false);
@@ -368,7 +368,7 @@ unsigned int ROMol::addBond(Bond *bond_pin, bool takeOwnership) {
bond_p->getEndAtomIdx(), d_graph);
CHECK_INVARIANT(ok, "bond could not be added");
d_graph[which].reset(bond_p);
int res = boost::num_edges(d_graph);
int res = rdcast<int>(boost::num_edges(d_graph));
bond_p->setIdx(res - 1);
return res;
}

View File

@@ -124,7 +124,7 @@ unsigned int RWMol::addAtom(bool updateLabel) {
cfi != this->endConformers(); ++cfi) {
(*cfi)->setAtomPos(which, RDGeom::Point3D(0.0, 0.0, 0.0));
}
return which;
return rdcast<unsigned int>(which);
}
void RWMol::replaceAtom(unsigned int idx, Atom *atom_pin, bool updateLabel) {
@@ -182,7 +182,7 @@ void RWMol::removeAtom(Atom *atom) {
ADJ_ITER b1, b2;
boost::tie(b1, b2) = getAtomNeighbors(atom);
while (b1 != b2) {
nbrs.push_back(std::make_pair(atom->getIdx(), *b1));
nbrs.push_back(std::make_pair(atom->getIdx(), rdcast<unsigned int>(*b1)));
++b1;
}
for (unsigned int i = 0; i < nbrs.size(); ++i) {
@@ -269,7 +269,7 @@ unsigned int RWMol::addBond(unsigned int atomIdx1, unsigned int atomIdx2,
MolGraph::edge_descriptor which;
boost::tie(which, ok) = boost::add_edge(atomIdx1, atomIdx2, d_graph);
d_graph[which].reset(b);
unsigned int res = boost::num_edges(d_graph);
unsigned int res = rdcast<unsigned int>(boost::num_edges(d_graph));
b->setIdx(res - 1);
b->setBeginAtomIdx(atomIdx1);
b->setEndAtomIdx(atomIdx2);
@@ -322,7 +322,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) {
ADJ_ITER a1, a2;
boost::tie(a1, a2) = boost::adjacent_vertices(aid1, d_graph);
while (a1 != a2) {
unsigned int oIdx = *a1;
unsigned int oIdx = rdcast<unsigned int>(*a1);
++a1;
if (oIdx == aid2) continue;
Bond *obnd = getBondBetweenAtoms(aid1, oIdx);
@@ -331,7 +331,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) {
}
boost::tie(a1, a2) = boost::adjacent_vertices(aid1, d_graph);
while (a1 != a2) {
unsigned int oIdx = *a1;
unsigned int oIdx = rdcast<unsigned int>(*a1);
++a1;
if (oIdx == aid1) continue;
Bond *obnd = getBondBetweenAtoms(aid2, oIdx);

View File

@@ -19,8 +19,8 @@ class CEVect2 {
public:
CEVect2(CEMap &ceMap);
ConjElectrons *getCE(unsigned int depth, unsigned int width);
unsigned int ceCount() { return d_ceVect.size(); }
unsigned int depth() { return d_degVect.size(); }
unsigned int ceCount() { return rdcast<unsigned int>(d_ceVect.size()); }
unsigned int depth() { return rdcast<unsigned int>(d_degVect.size()); }
void resize(unsigned int size);
void idxToDepthWidth(unsigned int idx, unsigned int &d, unsigned int &w);
unsigned int ceCountAtDepth(unsigned int depth);
@@ -527,8 +527,8 @@ bool ConjElectrons::storeFP(CEMap &ceMap, unsigned int flags) {
boost::uint8_t byte;
ConjFP fp;
unsigned int fpSize = 0;
if (flags & FP_ATOMS) fpSize += d_conjAtomMap.size();
if (flags & FP_BONDS) fpSize += ((d_conjBondMap.size() - 1) / 4 + 1);
if (flags & FP_ATOMS) fpSize += rdcast<unsigned int>(d_conjAtomMap.size());
if (flags & FP_BONDS) fpSize += rdcast<unsigned int>((d_conjBondMap.size() - 1) / 4 + 1);
fp.reserve(fpSize);
if (flags & FP_ATOMS) {
// for each atom, we push a byte to the FP vector whose
@@ -737,7 +737,7 @@ void ConjElectrons::enumerateNonBonded(CEMap &ceMap) {
// we compute the number of permutations (numComb) and a
// binary code (v) which indicates which of the atom indices in
// aiVec will be octet-unsatisfied for each permutation
ResonanceUtils::getNumCombStartV(numCand, aiVec.size(), numComb, v);
ResonanceUtils::getNumCombStartV(numCand, rdcast<unsigned int>(aiVec.size()), numComb, v);
// if there are multiple permutations, make a copy of the original
// ConjElectrons object, since the latter will be modified
ConjElectrons *ceCopy = ((numComb > 1) ? new ConjElectrons(*ce) : NULL);
@@ -809,8 +809,9 @@ void ConjElectrons::computeDistFormalCharges() {
for (ConjAtomMap::const_iterator it2 = it1; it2 != d_conjAtomMap.end();
++it2) {
if ((it1 == it2) || !it2->second->fc()) continue;
unsigned int dist = MolOps::getShortestPath(d_parent->mol(), it1->first,
it2->first).size();
unsigned int dist = rdcast<unsigned int>(
MolOps::getShortestPath(d_parent->mol(), it1->first,
it2->first).size());
if ((it1->second->fc() * it2->second->fc()) > 0)
d_ceMetrics.d_fcSameSignDist += dist;
else

View File

@@ -37,7 +37,7 @@ unsigned int RingInfo::numAtomRings(unsigned int idx) const {
PRECONDITION(df_init, "RingInfo not initialized");
if (idx < d_atomMembers.size()) {
return d_atomMembers[idx].size();
return rdcast<unsigned int>(d_atomMembers[idx].size());
} else {
return 0;
}
@@ -66,7 +66,7 @@ unsigned int RingInfo::numBondRings(unsigned int idx) const {
PRECONDITION(df_init, "RingInfo not initialized");
if (idx < d_bondMembers.size()) {
return d_bondMembers[idx].size();
return rdcast<unsigned int>(d_bondMembers[idx].size());
} else {
return 0;
}
@@ -75,14 +75,14 @@ unsigned int RingInfo::numBondRings(unsigned int idx) const {
unsigned int RingInfo::numRings() const {
PRECONDITION(df_init, "RingInfo not initialized");
PRECONDITION(d_atomRings.size() == d_bondRings.size(), "length mismatch");
return d_atomRings.size();
return rdcast<unsigned int>(d_atomRings.size());
}
unsigned int RingInfo::addRing(const INT_VECT &atomIndices,
const INT_VECT &bondIndices) {
PRECONDITION(df_init, "RingInfo not initialized");
PRECONDITION(atomIndices.size() == bondIndices.size(), "length mismatch");
int sz = atomIndices.size();
int sz = rdcast<int>(atomIndices.size());
for (INT_VECT::const_iterator i = atomIndices.begin(); i < atomIndices.end();
i++) {
if (*i >= static_cast<int>(d_atomMembers.size()))
@@ -98,7 +98,7 @@ unsigned int RingInfo::addRing(const INT_VECT &atomIndices,
d_atomRings.push_back(atomIndices);
d_bondRings.push_back(bondIndices);
POSTCONDITION(d_atomRings.size() == d_bondRings.size(), "length mismatch");
return d_atomRings.size();
return rdcast<unsigned int>(d_atomRings.size());
}
void RingInfo::initialize() {

View File

@@ -61,7 +61,7 @@ class SetQuery
typename CONTAINER_TYPE::const_iterator endSet() const {
return d_set.end();
};
unsigned int size() const { return d_set.size(); };
unsigned int size() const { return rdcast<unsigned int>(d_set.size()); };
std::string getFullDescription() const {
std::ostringstream res;

View File

@@ -63,7 +63,7 @@ class argless : public std::binary_function<T, T, bool> {
template <typename T1, typename T2>
void rankVect(const std::vector<T1> &vect, T2 &res) {
PRECONDITION(res.size() >= vect.size(), "vector size mismatch");
unsigned int nEntries = vect.size();
unsigned int nEntries = rdcast<unsigned int>(vect.size());
std::vector<unsigned int> indices(nEntries);
for (unsigned int i = 0; i < nEntries; ++i) indices[i] = i;

View File

@@ -17,6 +17,10 @@
#include <cassert>
#include <cstdlib>
#if defined(_MSC_VER)
#pragma warning(push, 1)
#pragma warning(disable: 4800)
#endif
namespace RDKit {
template <typename CompareFunc>
bool hanoi(int *base, int nel, int *temp, int *count, int *changed,
@@ -144,4 +148,8 @@ void hanoisort(int *base, int nel, int *count, int *changed,
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif /* HANOISORT_H_ */