inserts an item into the queue
(self, data)
| 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 | """ |
no outgoing calls