Ruby | SizedQueue << function Last Updated : 09 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The <<() is an inbuilt function in Ruby inserts the element in the SizedQueue. The SizedQueue have a particular capacity and cannot accept elements once it is full. Syntax: sq_name << element Parameters: The function takes the element to be inserted into the SizedQueue. Return Value: It inserts the element into the SizedQueue. Example 1: CPP #Ruby program for << function in SizedQueue #Create a new SizedQUEUE q1 q1 = SizedQueue.new(2) #push 5 q1 << 5 #push 6 q1 << 6 #Prints the element puts q1.pop puts q1.pop Output: 5 6 Example 2: CPP #Ruby program for << function in SizedQueue #Create a new SizedQUEUE q1 q1 = SizedQueue.new(3) #push 15 q1 << 15 #push 16 q1 << 16 #push 17 q1 << 17 #Prints the element puts q1.pop puts q1.pop puts q1.pop Output: 15 16 17 Reference: https://devdocs.io/ruby~2.5/sizedqueue#method-i-3C-3C Comment More infoAdvertise with us Next Article Ruby | SizedQueue << function gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Collections Ruby SizedQueue-class Similar Reads Ruby | SizedQueue length() function The length() is an inbuilt function in Ruby returns the current length of the SizedQueue or the number of objects present in it. It does not returns the pre-defined size of the SizedQueue Syntax: sq_name.length() Parameters: The function does not takes any parameter. Return Value: It returns the num 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 Ruby | SizedQueue new() function The new() is an inbuilt function in Ruby creates a new SizedQueue of the given name. Syntax: q_name = SizedQueue.new() Parameters: The function does not takes any parameter. Return Value: It creates a new SizedQueue. Example 1: CPP #Ruby program for new () function in SizedQueue #Create a new SizedQ 1 min read Ruby | SizedQueue max() function The max() is an inbuilt function in Ruby returns the maximum size of the SizedQueue. It returns the size using which the Queue was initialised. Syntax: sq_name.max() Parameters: The function does not takes any parameter. Return Value: It returns the size of the SizedQueue. Example 1: CPP #Ruby progr 1 min read Ruby | SizedQueue pop() function The pop() is an inbuilt function in Ruby returns the element in the front of the SizedQueue and removes it from the SizedQueue. Syntax: sq_name.pop() 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 push() function The push() is an inbuilt function in Ruby inserts the element in the SizedQueue. Syntax: sq_name.push(element) Parameters: The function takes the element to be inserted into the SizedQueue. Return Value: It inserts the element into the SizedQueue. Example 1: CPP #Ruby program for push() function in 1 min read Ruby | SizedQueue enq() function 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 d 1 min read 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 size() function The size() is an inbuilt function in Ruby returns the current size of the SizedQueue or the number of objects present in it. Syntax: sq_name.size() Parameters: The function does not takes any parameter. Return Value: It returns the number of elements in the SizedQueue. Example 1: CPP #Ruby program f 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 Like