Skip to content

Commit d1389ad

Browse files
committed
docs: use doxygen syntax
1 parent e5eec2a commit d1389ad

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

data_structures/queue.hpp

+30-6
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,46 @@ class queue {
1111

1212
public:
1313
using value_type = ValueType;
14-
/** Show queue */
14+
/**
15+
* @brief prints the queue into the std::cout
16+
*/
1517
void display() const {
1618
std::cout << "Front --> ";
1719
display_all(this->queueFront.get());
1820
std::cout << '\n';
1921
std::cout << "Size of queue: " << size << '\n';
2022
}
2123

24+
/**
25+
* @brief converts the queue into the std::vector
26+
* @return std::vector containning all of the elements of the queue in the
27+
* same order
28+
*/
2229
std::vector<value_type> toVector() const {
2330
return push_all_to_vector(this->queueFront.get(), this->size);
2431
}
2532

2633
private:
34+
/**
35+
* @brief throws an exception if queue is empty
36+
* @exception std::invalid_argument if queue is empty
37+
*/
2738
void ensureNotEmpty() const {
2839
if (isEmptyQueue()) {
2940
throw std::invalid_argument("Queue is empty.");
3041
}
3142
}
3243

3344
public:
34-
/** Determine whether the queue is empty */
45+
/**
46+
* @brief checks if the queue has no elements
47+
* @return true if the queue is empty, false otherwise
48+
*/
3549
bool isEmptyQueue() const { return (queueFront == nullptr); }
3650

37-
/** Add new item to the queue */
51+
/**
52+
* @brief inserts a new item into the queue
53+
*/
3854
void enQueue(const value_type& item) {
3955
auto newNode = std::make_shared<node_type>();
4056
newNode->data = item;
@@ -49,20 +65,28 @@ class queue {
4965
++size;
5066
}
5167

52-
/** Return the first element of the queue */
68+
/**
69+
* @return the first element of the queue
70+
* @exception std::invalid_argument if queue is empty
71+
*/
5372
value_type front() const {
5473
ensureNotEmpty();
5574
return queueFront->data;
5675
}
5776

58-
/** Remove the top element of the queue */
77+
/**
78+
* @brief removes the first element from the queue
79+
* @exception std::invalid_argument if queue is empty
80+
*/
5981
void deQueue() {
6082
ensureNotEmpty();
6183
queueFront = queueFront->next;
6284
--size;
6385
}
6486

65-
/** Clear queue */
87+
/**
88+
* @brief removes all of the elements of the queue
89+
*/
6690
void clear() {
6791
queueFront = nullptr;
6892
queueRear = nullptr;

0 commit comments

Comments
 (0)