Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

Consistent whitespace

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


Consistent whitespace

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


deleted 103 characters in body
Source Link
Summer
  • 2.4k
  • 2
  • 16
  • 31

const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


I will add more if I can (especially the two functions you sought out) but for now I must step off.

const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


I will add more if I can (especially the two functions you sought out) but for now I must step off.

const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


Source Link
Summer
  • 2.4k
  • 2
  • 16
  • 31

const int maxsize = 5;

A couple of things here. First you should prefer constexpr. But furthermore I am curious why you have a maxsize of 5. You may have a good reason, but if you do it would probably be good to document the decision because it isn't implicitly obvious. Is it completely arbitrary? You could document that if it is the case.


int front, rear,n;

Don't declare multiple variable on the same line. You do this many many times throughout the code both with declarations and operations.


##Consistent whitespace##

The spacing between your operators isn't consistent.

Sometimes your have this:

for (int i = 0; i < q.n; i++)

and sometimes this:

for (i = (front+1)%maxsize; i != (rear+1)%maxsize; increment(i))

The spacing improves readability but it is also far more glaring and irksome when it changes like that.


prefer prefix over postfix


if (front == rear)
 return true;
else
 return false;

any time you return true and false from a conditional like that you are likely overwriting your code.

return front == rear;

should suffice.


I will add more if I can (especially the two functions you sought out) but for now I must step off.

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /