MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / enqueue

Method enqueue

pygorithm/data_structures/queue.py:37–53  ·  view source on GitHub ↗

inserts an item into the queue

(self, data)

Source from the content-addressed store, hash-verified

35 return self.size <= 0
36
37 def enqueue(self, data):
38 """
39 inserts an item into the queue
40 """
41 if self.size >= self.limit:
42 # queue overflow
43 return -1
44 else:
45 self.queue.append(data)
46
47 # assign the rear as size of the queue and front as 0
48 if self.front is None:
49 self.front = self.rear = 0
50 else:
51 self.rear = self.size
52
53 self.size += 1
54
55 def dequeue(self):
56 """

Callers 2

test_queueMethod · 0.95
insertMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_queueMethod · 0.76