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

Method first

data_structures/queues/circular_queue.py:39–48  ·  view source on GitHub ↗

Returns the first element of the queue >>> cq = CircularQueue(5) >>> cq.first() False >>> cq.enqueue("A").first() 'A'

(self)

Source from the content-addressed store, hash-verified

37 return self.size == 0
38
39 def first(self):
40 """
41 Returns the first element of the queue
42 >>> cq = CircularQueue(5)
43 >>> cq.first()
44 False
45 >>> cq.enqueue("A").first()
46 'A'
47 """
48 return False if self.is_empty() else self.array[self.front]
49
50 def enqueue(self, data):
51 """

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.95

Tested by

no test coverage detected