Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update circular_queue.cpp #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}