Ruby | SizedQueue enq() function Last Updated : 09 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The enq() is an inbuilt function in Ruby inserts the element in the SizedQueue till it does not reaches its maximum capacity. Syntax: sq_name.enq(element) Parameters: The function takes the element to be inserted into the SizedQueue. Return Value: It inserts the element into the SizedQueue till it does not reaches its fixed capacity. Example 1: CPP #Ruby program for enq() function in SizedQueue #Create a new SizedQueue q1 sq1 = SizedQueue.new(2) #pushes 5 sq1.enq(5) #pushes 6 sq1.enq(6) #Prints the element puts sq1.pop puts sq1.pop Output: 5 6 Example 2: CPP #Ruby program for enq() function in SizedQueue #Create a new SizedQueue q1 sq1 = SizedQueue.new(2) #push 10 sq1.enq(10) #push 12 sq1.enq(12) #Prints the element puts sq1.pop #Again pushes 13 sq1.enq(13) #Prints the element puts sq1.pop #Prints the element puts sq1.pop Output: 10 12 13 Reference: https://devdocs.io/ruby~2.5/sizedqueue#method-i-enq Comment More infoAdvertise with us Next Article Ruby | SizedQueue enq() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Collections Ruby SizedQueue-class Similar Reads Ruby | SizedQueue deq() function The deq() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.deq() Parameters: The function does not takes any element. Return Value: It returns the first element which is at the front of the SizedQueue and removes it 1 min read Ruby | SizedQueue close() function The close() is an inbuilt function in Ruby closes the SizedQueue permanently, and does not allows any more push or pop operations in it. A closed SizedQueue cannot be re-opened. Syntax: sq_name.close() Parameters: The function does not takes any element. Return Value: It closes the SizedQueue and d 1 min read Ruby | SizedQueue clear() function The clear() is an inbuilt function in Ruby clears the SizedQueue. We can re-insert objects again to it till the declared size of the SizedQueue. Syntax: q_name.clear() Parameters: The function does not takes any element. Return Value: It clears the SizedQueue and does not returns anything. Example 1 1 min read Ruby | SizedQueue empty? function The empty? is an inbuilt function in Ruby checks if the SizedQueue is empty or not?. It returns a boolean value, which is true if the SizedQueue is empty or it returns false. Empty here means if it contains elements or not in it. Syntax: sq_name.empty? Parameters: The function does not takes any ele 1 min read Ruby | SizedQueue max= function The max=() is an inbuilt function in Ruby changes the current capacity of the SizedQueue and sets it into X, where X is given by the user. Syntax: sq_name.max=X() Parameters: The function accepts a single mandatory parameter and changes the current size of the SizedQueue to X. Return Value: It sets 1 min read Like