<jupyter_start><jupyter_text>Author: <NAME>  What is a Queue? * A queue is a data structure used for storing data (similar to Linked Lists and stacks). In queue, the order in which dula arrives is important.* A queue is an ordered list in which insertions are done at one end (rear) and deletions are done at other end (front). The first element to be inserted is the first one to be deleted. Hence, it is called First in First out (FIFO) or Last in Last out (LILO) list.* For example, our labs have 30 computers networked with a single printer. When students want to print, their print tasks “get in line” with all the other printing tasks that are waiting. The first task in is the next to be completed.  Applications of Queue: *  When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling.* When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes. Examples include IO Buffers, pipes, file IO, etc.* Keyboard: As we type, sometimes keystrokes get ahead of the characters that appear on the screen. This is due to the computer doing other work at that moment. The keystrokes are being placed in a queue-like buffer so that they can eventually be displayed on the screen in the proper order.<jupyter_code>class Queue(object):
    def __init__(self, limit = 10):
        self.queue = []
        self.front = None
        self.rear = None
        self.limit = limit
        self.size = 0
     
    def __str__(self):
        return ' '.join([str(i) for i in self.queue])
    
    # to check if queue is empty
    def isEmpty(self):
        return self.size <= 0
    
    # to add an element from the rear end of the queue
    def enqueue(self, data):
        if self.size >= self.limit:
            return -1          # queue overflow
        else:
            self.queue.append(data)
        
        # assign the rear as size of the queue and front as 0
        if self.front is None:
            self.front = self.rear = 0
        else:
            self.rear = self.size
            
        self.size += 1
    
    # to pop an element from the front end of the queue
    def dequeue(self):
        if self.isEmpty():
            return -1          # queue underflow
        else:
            self.queue.pop()
            self.size -= 1
            if self.size == 0:
                self.front = self.rear = 0
            else:
                self.rear = self.size - 1
    
    def getSize(self):
        return self.size

myQueue = Queue()
for i in range(10):
    myQueue.enqueue(i)
print(myQueue)
print('Queue Size:',myQueue.getSize())
myQueue.dequeue()
print(myQueue)
print('Queue Size:',myQueue.getSize())<jupyter_output>0 1 2 3 4 5 6 7 8 9
Queue Size: 10
0 1 2 3 4 5 6 7 8
Queue Size: 9
{'fraction_non_alphanumeric': 0.07191413237924865, 'fraction_numerical': 0.013953488372093023, 'mean_word_length': 2.3565426170468187, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '313651', 'license': 'MIT', 'n_tokens_mistral': 809, 'n_tokens_neox': 759, 'n_words': 374, 'path': 'Queue/Queue.ipynb', 'repo_name': 'akhilesh1806/DataStructures-using-python', 'size': '2808'}