MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __len__

Method __len__

data_structures/queues/circular_queue.py:14–26  ·  view source on GitHub ↗

>>> cq = CircularQueue(5) >>> len(cq) 0 >>> cq.enqueue("A") # doctest: +ELLIPSIS >>> cq.array ['A', None, None, None, None] >>> len(cq) 1

(self)

Source from the content-addressed store, hash-verified

12 self.size = 0
13
14 def __len__(self) -> int:
15 """
16 >>> cq = CircularQueue(5)
17 >>> len(cq)
18 0
19 >>> cq.enqueue("A") # doctest: +ELLIPSIS
20 <data_structures.queues.circular_queue.CircularQueue object at ...>
21 >>> cq.array
22 ['A', None, None, None, None]
23 >>> len(cq)
24 1
25 """
26 return self.size
27
28 def is_empty(self) -> bool:
29 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected