Skip to content

Conversation

wildart
Copy link
Contributor

@wildart wildart commented May 2, 2015

Multi-valued dictionary implementation based on Dict{K,Vector{V}}. It behaves as normal dictionary only

  • setindex! appends new elements to the value vector
  • pop! removes the last element from the value vector & if the value vector is empty removes key

Some additional functions were added

  • enumerateall creates enumerator through all (k,v) pairs in the dictionary
  • count counts all values in the dictionary ( length returns number of keys)
  • size returns number of keys & values in the dictionary

@wildart
Copy link
Contributor Author

wildart commented May 2, 2015

I wonder maybe size would be better way present element count information, so it would return

(#key, #value) =  size(d)

@IainNZ
Copy link
Contributor

IainNZ commented May 8, 2015

It'd be good to somehow knock this and #88 at the same time

@StephenVavasis
Copy link
Contributor

@IainNZ, @wildart, @kmsquire

I can add analogous functions to mimic this functionality to SortedMultiDict, but I have a few concerns:

m[k] = newitem: the proposal here is that this operation acts like a 'push!' instead of an assignment statement, which seems to me inconsistent with the use of assignment elsewhere in Julia. Perhaps '+=' instead of '='. What do other readers think?

MultiDict <: Associative: MultiDict does not implement the Associative interface, so I think this subtype declaration should be omitted

@malmaud
Copy link
Contributor

malmaud commented Aug 14, 2015

Ping @wildart, would be useful to have this. I vote for using insert!(m, k, newitem) (as SortedMultiDict does) instead of m[k]=newitem to be more consistent with expectations of assignment.

@malmaud malmaud mentioned this pull request Aug 15, 2015
@malmaud
Copy link
Contributor

malmaud commented Nov 10, 2015

Superceded by #115

@malmaud malmaud closed this Nov 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants