Less use of "this"
This commit is contained in:
@ -52,8 +52,8 @@ class CircularQueue {
|
||||
* items that can be stored on the queue.
|
||||
*/
|
||||
CircularQueue<T, N>() {
|
||||
this->buffer.size = N;
|
||||
this->buffer.count = this->buffer.head = this->buffer.tail = 0;
|
||||
buffer.size = N;
|
||||
buffer.count = buffer.head = buffer.tail = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,15 +63,15 @@ class CircularQueue {
|
||||
* @return type T item
|
||||
*/
|
||||
T dequeue() {
|
||||
if (this->isEmpty()) return T();
|
||||
if (isEmpty()) return T();
|
||||
|
||||
uint8_t index = this->buffer.head;
|
||||
uint8_t index = buffer.head;
|
||||
|
||||
--this->buffer.count;
|
||||
if (++this->buffer.head == this->buffer.size)
|
||||
this->buffer.head = 0;
|
||||
--buffer.count;
|
||||
if (++buffer.head == buffer.size)
|
||||
buffer.head = 0;
|
||||
|
||||
return this->buffer.queue[index];
|
||||
return buffer.queue[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,13 +82,13 @@ class CircularQueue {
|
||||
* @return true if the operation was successful
|
||||
*/
|
||||
bool enqueue(T const &item) {
|
||||
if (this->isFull()) return false;
|
||||
if (isFull()) return false;
|
||||
|
||||
this->buffer.queue[this->buffer.tail] = item;
|
||||
buffer.queue[buffer.tail] = item;
|
||||
|
||||
++this->buffer.count;
|
||||
if (++this->buffer.tail == this->buffer.size)
|
||||
this->buffer.tail = 0;
|
||||
++buffer.count;
|
||||
if (++buffer.tail == buffer.size)
|
||||
buffer.tail = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -98,27 +98,21 @@ class CircularQueue {
|
||||
* @details Returns true if there are no items on the queue, false otherwise.
|
||||
* @return true if queue is empty
|
||||
*/
|
||||
bool isEmpty() {
|
||||
return this->buffer.count == 0;
|
||||
}
|
||||
bool isEmpty() { return buffer.count == 0; }
|
||||
|
||||
/**
|
||||
* @brief Checks if the queue is full
|
||||
* @details Returns true if the queue is full, false otherwise.
|
||||
* @return true if queue is full
|
||||
*/
|
||||
bool isFull() {
|
||||
return this->buffer.count == this->buffer.size;
|
||||
}
|
||||
bool isFull() { return buffer.count == buffer.size; }
|
||||
|
||||
/**
|
||||
* @brief Gets the queue size
|
||||
* @details Returns the maximum number of items a queue can have.
|
||||
* @return the queue size
|
||||
*/
|
||||
uint8_t size() {
|
||||
return this->buffer.size;
|
||||
}
|
||||
uint8_t size() { return buffer.size; }
|
||||
|
||||
/**
|
||||
* @brief Gets the next item from the queue without removing it
|
||||
@ -126,16 +120,12 @@ class CircularQueue {
|
||||
* or updating the pointers.
|
||||
* @return first item in the queue
|
||||
*/
|
||||
T peek() {
|
||||
return this->buffer.queue[this->buffer.head];
|
||||
}
|
||||
T peek() { return buffer.queue[buffer.head]; }
|
||||
|
||||
/**
|
||||
* @brief Gets the number of items on the queue
|
||||
* @details Returns the current number of items stored on the queue.
|
||||
* @return number of items in the queue
|
||||
*/
|
||||
uint8_t count() {
|
||||
return this->buffer.count;
|
||||
}
|
||||
uint8_t count() { return buffer.count; }
|
||||
};
|
||||
|
Reference in New Issue
Block a user