Added documentations (#11352)

* Added documentations

* Update data_structures/queue/circular_queue.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Jiayou Qin 2024-04-08 07:35:22 -04:00 committed by GitHub
parent cc2f5b1308
commit 9e55c9d984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -25,6 +25,7 @@ class CircularQueue:
def is_empty(self) -> bool: def is_empty(self) -> bool:
""" """
Checks whether the queue is empty or not
>>> cq = CircularQueue(5) >>> cq = CircularQueue(5)
>>> cq.is_empty() >>> cq.is_empty()
True True
@ -35,6 +36,7 @@ class CircularQueue:
def first(self): def first(self):
""" """
Returns the first element of the queue
>>> cq = CircularQueue(5) >>> cq = CircularQueue(5)
>>> cq.first() >>> cq.first()
False False
@ -45,7 +47,8 @@ class CircularQueue:
def enqueue(self, data): def enqueue(self, data):
""" """
This function insert an element in the queue using self.rear value as an index This function inserts an element at the end of the queue using self.rear value
as an index.
>>> cq = CircularQueue(5) >>> cq = CircularQueue(5)
>>> cq.enqueue("A") # doctest: +ELLIPSIS >>> cq.enqueue("A") # doctest: +ELLIPSIS
<data_structures.queue.circular_queue.CircularQueue object at ... <data_structures.queue.circular_queue.CircularQueue object at ...
@ -67,7 +70,7 @@ class CircularQueue:
def dequeue(self): def dequeue(self):
""" """
This function removes an element from the queue using on self.front value as an This function removes an element from the queue using on self.front value as an
index index and returns it
>>> cq = CircularQueue(5) >>> cq = CircularQueue(5)
>>> cq.dequeue() >>> cq.dequeue()
Traceback (most recent call last): Traceback (most recent call last):

View File

@ -39,7 +39,7 @@ class CircularQueueLinkedList:
def is_empty(self) -> bool: def is_empty(self) -> bool:
""" """
Checks where the queue is empty or not Checks whether the queue is empty or not
>>> cq = CircularQueueLinkedList() >>> cq = CircularQueueLinkedList()
>>> cq.is_empty() >>> cq.is_empty()
True True