Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. AQue::AQue()
  2. {
  3. _indexOfFront = 0;
  4. _size = 0;
  5. _capacity = 10;
  6. _theArr = new float[_capacity];
  7. }
  8.  
  9. AQue::~AQue()
  10. {
  11. delete [] _theArr;
  12. }
  13.  
  14. void AQue::pushBack(float value)
  15. {
  16. int back = (_indexOfFront + _size) % _capacity;
  17. _theArr[back] = value;
  18. _size += 1;
  19. }
  20.  
  21. float &AQue::back()
  22. {
  23. assert( _size > 0 );
  24. if( _size == 10 )
  25. return _theArr[_capacity-1];
  26.  
  27. int back = (_indexOfFront + _size) % _capacity;
  28. return _theArr[back-1];
  29. }
  30.  
  31. void AQue::popFront()
  32. {
  33. assert( _size > 0 );
  34. _indexOfFront = (_indexOfFront + 1) % _capacity;
  35. _size -= 1;
  36. }
  37.  
  38. float &AQue::front()
  39. {
  40. assert( _size > 0 );
  41. return _theArr[_indexOfFront];
  42. }
  43.  
  44. int AQue::size()
  45. {
  46. return _size;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement