UnitsQueue.cpp 741 B

123456789101112131415161718192021222324252627282930313233
  1. #include "UnitsQueue.h"
  2. #include <vector>
  3. #include <string>
  4. void UnitsQueue::add(Unit* unit){
  5. queue_.push_back(unit);
  6. }
  7. void UnitsQueue::remove(viterator iter){
  8. if (beginIterator() <= iter && iter < endIterator()){
  9. queue_.erase(iter);
  10. return;
  11. }
  12. throw std::string("Iterator is not in UnitsQueue");
  13. }
  14. void UnitsQueue::remove(Unit* unit){
  15. for (viterator it = beginIterator(); it != endIterator();++it){
  16. if( (*it) == unit){
  17. remove(it);
  18. return;
  19. }
  20. }
  21. throw std::string("Unit* is not in UnitsQueue");
  22. }
  23. UnitsQueue::viterator UnitsQueue::beginIterator() {
  24. return queue_.begin();
  25. }
  26. UnitsQueue::viterator UnitsQueue::endIterator(){
  27. return queue_.end();
  28. }