Skip to content

Commit

Permalink
Added documentations (TheAlgorithms#11352)
Browse files Browse the repository at this point in the history
* Added documentations

* Update data_structures/queue/circular_queue.py

---------

Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
Jiayoqin and cclauss authored Apr 8, 2024
1 parent cc2f5b1 commit 9e55c9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions data_structures/queue/circular_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __len__(self) -> int:

def is_empty(self) -> bool:
"""
Checks whether the queue is empty or not
>>> cq = CircularQueue(5)
>>> cq.is_empty()
True
Expand All @@ -35,6 +36,7 @@ def is_empty(self) -> bool:

def first(self):
"""
Returns the first element of the queue
>>> cq = CircularQueue(5)
>>> cq.first()
False
Expand All @@ -45,7 +47,8 @@ def first(self):

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.enqueue("A") # doctest: +ELLIPSIS
<data_structures.queue.circular_queue.CircularQueue object at ...
Expand All @@ -67,7 +70,7 @@ def enqueue(self, data):
def dequeue(self):
"""
This function removes an element from the queue using on self.front value as an
index
index and returns it
>>> cq = CircularQueue(5)
>>> cq.dequeue()
Traceback (most recent call last):
Expand Down
2 changes: 1 addition & 1 deletion data_structures/queue/circular_queue_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_linked_list(self, initial_capacity: int) -> None:

def is_empty(self) -> bool:
"""
Checks where the queue is empty or not
Checks whether the queue is empty or not
>>> cq = CircularQueueLinkedList()
>>> cq.is_empty()
True
Expand Down

0 comments on commit 9e55c9d

Please sign in to comment.