Small dictionaries

SmallCollections.SmallDictType
SmallDict{N,K,V} <: AbstractSmallDict{N,K,V}

SmallDict{N,K,V}()
SmallDict{N,K,V}(itr; unique = itr isa AbstractDict)
SmallDict{N,K,V}(key1 => val1, key2 => val2, ...; unique = false)

An immutable dictionary with key type K and value type V that can store up to N entries. All entries come from the key-value iterator itr provided at construction time or from the explicitly given pairs.

If the key and value types are omitted, they will be inferred from the pairs or, if possible, from the iterator. If unique is set to true, then the elements of itr are assumed to have distinct keys.

See also AbstractSmallDict, MutableSmallDict.

Examples

julia> SmallDict{8}(Int16(1) => 2, Int32(3) => 4.0)
SmallDict{8, Int32, Float64} with 2 entries:
  1 => 2.0
  3 => 4.0

julia> SmallDict{8,Char,Int}('a'+k => k^2 for k in 0:2; unique = true)
SmallDict{8, Char, Int64} with 3 entries:
  'a' => 0
  'b' => 1
  'c' => 4
source
SmallCollections.MutableSmallDictType
MutableSmallDict{N,K,V} <: AbstractSmallDict{N,K,V}

MutableSmallDict{N,K,V}()
MutableSmallDict{N,K,V}(itr; unique = itr isa AbstractDict)
MutableSmallDict{N,K,V}(key1 => val1, key2 => val2, ...; unique = false)

An dictionary with key type K and value type V that can store up to N entries. The dictionary is mutable and implements Julia's dictionary interface.

If the key and value types are omitted, they will be inferred from the pairs or, if possible, from the iterator. If unique is set to true, then the elements of itr are assumed to have distinct keys.

See also AbstractSmallDict, SmallDict.

Examples

julia> d = MutableSmallDict{8}('a' => 0, 'b' => 1, 'c' => 4)
MutableSmallDict{8, Char, Int64} with 3 entries:
  'a' => 0
  'b' => 1
  'c' => 4


julia> delete!(d, 'b')
MutableSmallDict{8, Char, Int64} with 2 entries:
  'a' => 0
  'c' => 4
source
SmallCollections.capacityMethod
capacity(::Type{<:AbstractSmallDict}) -> Int
capacity(d::AbstractSmallDict) -> Int

Return the largest number of elements the given dictionary type can hold.

source
Base.emptyMethod
empty(d::AbstractSmallDict{N,K,V}) where {N,K,V,W} -> AbstractSmallVector{N,K,V}
empty(d::AbstractSmallDict{N,K,V}, W::Type) where {N,K,V,W} -> AbstractSmallVector{N,K,W}
empty(d::AbstractSmallDict{N,K,V}, L::Type, W::Type) where {N,K,V,L,W} -> AbstractSmallVector{N,L,W}

Return an empty AbstractSmallDictionary with the same capacity as d, and with valtype changed to W and keytype changed to L if so specified. The resulting dictionary is mutable if and only if d is so.

source
Base.setindexMethod
setindex(d::AbstractSmallDict{N,K,V}, val, key) where {N,K,V} -> Tuple{SmallDict{N,K,V}, V}

Return the dictionary that is obtained from d by adding the mapping key => val.

See also Base.setindex!, push.

source
SmallCollections.pushMethod
push(d::AbstractSmallDict{N,K,V}, key1 => val1, key2 => val2, ...) where {N,K,V} -> Tuple{SmallDict{N,K,V}, V}

Return the dictionary that is obtained from d by adding the mappings given as arguments.

See also Base.push!, setindex.

source
SmallCollections.popMethod
pop(d::AbstractSmallDict{N,K,V}) where {N,K,V} -> Tuple{SmallDict{N,K,V}, Pair{K,V}}

Remove a mapping key => val from d and return the new dictionary together with the mapping. The dictionary d must not be empty.

See also Base.pop!.

source
SmallCollections.popMethod
pop(d::AbstractSmallDict{N,K,V}, key) where {N,K,V} -> Tuple{SmallDict{N,K,V}, V}

Remove the mapping for key from d and return the new dictionary together with the value d[key].

See also Base.pop!, delete.

source
SmallCollections.popMethod
pop(d::AbstractSmallDict{N,K,V}, key, default::U) where {N,K,V,U} -> Tuple{SmallDict{N,K,V}, Union{V,U}}

If d has the key key, remove it and return the new dictionary together with d[key]. Otherwise return the tuple (SmallDict(d), default).

See also Base.pop!.

source
SmallCollections.deleteMethod
delete(d::AbstractSmallDict{N,K,V}, key) where {N,K,V} -> SmallDict{N,K,V}

Remove the mapping for key from d (if it exists) and return the new dictionary.

See also Base.delete!, pop.

source