Skip to content

Commit

Permalink
Update circular_queue.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
manika88 authored Dec 31, 2024
1 parent c154de8 commit e93b1b2
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions task3/circular_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,66 @@

CircularQueue::CircularQueue(size_t size)
{
// your implementation here
CircularQueue::CircularQueue(size_t max_size) : {
mass.resize(max_size);
}

bool CircularQueue::Push(int value)
{
// your implementation here
if (Full()) {
return false;
}
else{
mass[end] = value;
end = (end + 1) % capacity;
end++;
return true;
}
}

bool CircularQueue::Pop()
{
// your implementation here
if (Full()) {
return false;
}
else{
end = (end - 1) % capacity;
size--;
return true;
}
}

int CircularQueue::Front() const
{
// your implementation here
if(Empty())
{
return -1;
}
else
{
return mass[front];
}
}

int CircularQueue::Back() const
{
// your implementation here
if(Empty())
{
return -1;
}
else
{
return mass[end];
}
}

bool CircularQueue::Empty() const
{
// your implementation here

return size == 0;
}

bool CircularQueue::Full() const
{
// your implementation here
return size == capacity;
}

0 comments on commit e93b1b2

Please sign in to comment.