mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
add support for integer arithmatic ops on SparseIntVects. operator+ et al. do not yet work from python
This commit is contained in:
@@ -260,6 +260,62 @@ namespace RDKit{
|
||||
SparseIntVect<IndexType> res(*this);
|
||||
return res-=other;
|
||||
}
|
||||
SparseIntVect<IndexType> &
|
||||
operator*= (int v) {
|
||||
typename StorageType::iterator iter=d_data.begin();
|
||||
while(iter!=d_data.end()){
|
||||
iter->second *= v;
|
||||
++iter;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator* (int v) {
|
||||
SparseIntVect<IndexType> res(*this);
|
||||
return res*=v;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator/= (int v) {
|
||||
typename StorageType::iterator iter=d_data.begin();
|
||||
while(iter!=d_data.end()){
|
||||
iter->second /= v;
|
||||
++iter;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator/ (int v) {
|
||||
SparseIntVect<IndexType> res(*this);
|
||||
return res/=v;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator+= (int v) {
|
||||
typename StorageType::iterator iter=d_data.begin();
|
||||
while(iter!=d_data.end()){
|
||||
iter->second += v;
|
||||
++iter;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator+ (int v) {
|
||||
SparseIntVect<IndexType> res(*this);
|
||||
return res+=v;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator-= (int v) {
|
||||
typename StorageType::iterator iter=d_data.begin();
|
||||
while(iter!=d_data.end()){
|
||||
iter->second -= v;
|
||||
++iter;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
SparseIntVect<IndexType> &
|
||||
operator- (int v) {
|
||||
SparseIntVect<IndexType> res(*this);
|
||||
return res-=v;
|
||||
};
|
||||
|
||||
bool operator==(const SparseIntVect<IndexType> &v2) const{
|
||||
if(d_length!=v2.d_length){
|
||||
|
||||
Reference in New Issue
Block a user