lifo/src/lifo/lifolike.cr
2021-11-20 13:14:36 +01:00

20 lines
339 B
Crystal

module Lifo
abstract class LifoLike(T)
protected property data = [] of T
getter capacity
def initialize(@capacity = -1)
if @capacity < -1
raise ArgumentError.new("capacity must be >= -1")
end
end
def size : Int32
@data.size
end
def empty? : Bool
size == 0
end
end
end