pull/1/head
matthieugomez 2015-10-23 19:15:03 -04:00
parent 5dc1a1d68f
commit 73f80c8271
1 changed files with 4 additions and 4 deletions

View File

@ -21,14 +21,14 @@ type Bag{Tv, Ti <: Integer}
end end
function Base.push!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv) function Base.push!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv)
bag.dict[x] = get(bag.dict, x, zero(UInt)) + one(UInt) bag.dict[x] = get(bag.dict, x, zero(Ti)) + one(Ti)
return bag return bag
end end
function Base.delete!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv) function Base.delete!{Tv, Ti}(bag::Bag{Tv, Ti}, x::Tv)
v = get(bag.dict, x, zero(UInt)) v = get(bag.dict, x, zero(Ti))
if v > zero(UInt) if v > zero(Ti)
bag.dict[x] = v - one(UInt) bag.dict[x] = v - one(Ti)
end end
return x return x
end end