Merged get_avg function in PeekableQueue class.