pull/1/head
matthieugomez 2015-10-23 10:29:41 -04:00
parent 023f9b0e61
commit c0f2cc58f6
1 changed files with 4 additions and 1 deletions

View File

@ -28,7 +28,10 @@ function Bag(s::AbstractString, q::Integer)
end
Base.in{Tv <: Union{Char, AbstractString}, Ti}(x::Tv, bag::Bag{Tv, Ti}) = get(bag.dict, x, 0) > 0
Base.pop!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv) = bag.dict[x] -= 1 ; x
function Base.pop!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv)
bag.dict[x] -= 1
return x
end
Base.length(bag::Bag) = sum(values(bag.dict))
##############################################################################