Add simple stack implementation

This commit is contained in:
Chris Roberts 2021-10-06 08:41:30 -07:00 committed by Paul Hinze
parent 66f8643ae3
commit 6d682ab7eb
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -0,0 +1,45 @@
module VagrantPlugins
module CommandServe
class Mappers
module Internal
# Simple stack implementation
class Stack
def initialize
@data = []
@m = Mutex.new
end
def include?(v)
@m.synchronize do
@data.include?(v)
end
end
def pop
@m.synchronize do
@data.pop
end
end
def push(v)
@m.synchronize do
@data.push(v)
end
end
def size
@m.synchronize do
@data.size
end
end
def values
@m.synchronize do
@data.dup
end
end
end
end
end
end
end