Guest User

Untitled

a guest
Jan 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. /*
  2.  * BondList.cpp
  3.  *
  4.  *  Created on: Oct 10, 2012
  5.  *      Author: jbirchfield
  6.  */
  7.  
  8. #include "BondList.h"
  9. #include "Atom.h"
  10. #include <algorithm>
  11. #include <deque>
  12. #include <iostream>
  13.  
  14.  
  15. using namespace std;
  16. BondList::BondList() {
  17.  
  18. }
  19.  
  20. BondList::~BondList() {
  21.     //TODO does anything need to be deleted here?  perhaps left or right?
  22.     //delete(left);
  23.     //delete(right);
  24. }
  25.  
  26. //TODO why do I get an error if I put const in front of Bond&
  27. //TODO why is this never getting called?
  28. static  bool sortBond(Bond _left, Bond _right) {
  29.     std::cout<<"sorting"<<std::endl;
  30.     Atom& first  = _left.getLeftAtom();
  31.     Atom& second  = _right.getLeftAtom();
  32.     return (first.getPosition() < second.getPosition());
  33. }
  34.  
  35. bool BondList::isBondsRemaining() {
  36.     return bonds.size() > 0;
  37. }
  38. void BondList::addBond(const Bond& _bond) {
  39.     std::cout<<"About to sort"<<std::endl;
  40.     sort(bonds.begin(), bonds.end(), &sortBond);
  41.     bonds.push_back(_bond);
  42.  
  43. }
  44. Bond& BondList::popBond() {
  45.     Bond& bond = bonds.front();
  46.     bonds.pop_front();
  47. //  sort(bonds.begin(), bonds.end(), sortBond);
  48.     return bond;
  49. }
Add Comment
Please, Sign In to add comment