Several enhancements and fixes

This commit is contained in:
krahets
2023-09-14 03:36:31 +08:00
parent a9d70e9e4b
commit d190dbf3c1
18 changed files with 84 additions and 70 deletions

View File

@ -37,7 +37,7 @@ class ArrayQueue {
}
/* 判断队列是否为空 */
bool empty() {
bool isEmpty() {
return size() == 0;
}
@ -65,7 +65,7 @@ class ArrayQueue {
/* 访问队首元素 */
int peek() {
if (empty())
if (isEmpty())
throw out_of_range("队列为空");
return nums[front];
}
@ -110,7 +110,7 @@ int main() {
cout << "队列长度 size = " << size << endl;
/* 判断队列是否为空 */
bool empty = queue->empty();
bool empty = queue->isEmpty();
cout << "队列是否为空 = " << empty << endl;
/* 测试环形数组 */