Skip to content

Commit

Permalink
Permit non-number types in Accumulator (JuliaCollections#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov committed Jul 11, 2023
1 parent e62f469 commit e3fa7b6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/accumulator.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#A counter type

"""
Accumulator{T, V<:Number}
Accumulator{T, V}
A accumulator is a data structure that maintains an accumulated total for each key.
The particular case where those totals are integers is a counter.
"""
struct Accumulator{T, V <: Number} <: AbstractDict{T, V}
struct Accumulator{T, V} <: AbstractDict{T, V}
map::Dict{T, V}
end

## constructors

Accumulator{T, V}() where {T, V <: Number} = Accumulator{T, V}(Dict{T, V}())
Accumulator{T, V}() where {T, V} = Accumulator{T, V}(Dict{T, V}())
Accumulator(map::AbstractDict) = Accumulator(Dict(map))
Accumulator(ps::Pair...) = Accumulator(Dict(ps))

Expand Down

0 comments on commit e3fa7b6

Please sign in to comment.