class

PriorityQueue(T)

Inherits Bisect::Helper < Array < Comparable < Indexable::Mutable < Indexable < Enumerable < Iterable < Reference < Object

Instance methods

<<(item : T)

Append. Alias for push.

a = [1, 2]
a << 3 # => [1,2,3]
Source
push(item : T)

Append. Pushes one value to the end of self, given that the type of the value is T (which might be a single type or a union of types). This method returns self, so several calls can be chained. See pop for the opposite effect.

a = ["a", "b"]
a.push("c") # => ["a", "b", "c"]
a.push(1)   # Errors, because the array only accepts String.

a = ["a", "b"] of (Int32 | String)
a.push("c") # => ["a", "b", "c"]
a.push(1)   # => ["a", "b", "c", 1]
Source
push(*items : T)

Append multiple values. The same as push, but takes an arbitrary number of values to push into self. Returns self.

a = ["a"]
a.push("b", "c") # => ["a", "b", "c"]
Source