stanch / reftree

Automatically generated diagrams and animations for Scala data structures
http://stanch.github.io/reftree/
GNU General Public License v3.0
587 stars 36 forks source link

Add ToRefTree instance for Map #4

Closed julien-truffaut closed 7 years ago

stanch commented 7 years ago

Currently I don’t have any generic instances, e.g. for sets I have s.c.i.HashSet and s.c.i.TreeSet. Adding s.c.i.HashMap and s.c.i.TreeMap should be trivial (especially the latter, since it reuses 99% of the code of s.c.i.TreeSet). Now, Map points to s.c.i.Map, which can be a multitude of things. If the map is created via Map.apply, it will always be a Map1, Map2, Map3, Map4 or a HashMap. I can add an instance for Map with that assumption, but it will break if some other map is passed in. Likewise, an instance for Seq can be added that assumes a List (the default for Seq.apply), but it would fail on everything else. What do you think?

julien-truffaut commented 7 years ago

You're right it makes sense for you to provide diagram for concrete implementations. I am mainly interested by a simple Map diagram in order to visualise Json

stanch commented 7 years ago

In that case what do you think about adding the following?

stanch commented 7 years ago

I’m open to suggestions w.r.t. the simple map representation. My current idea is to have something like this:

             +--------+---------+---------+
             |        |         |         |
             |  Map   |    •    |    •    |
             |        |         |         |
             +--------+----X----+----X----+
                           X         XX
                          XX          X
        XXXXXXXXXXXXXXXXXX            X
    XXXXX                             X
+---X---+-----+-----+             +---X---+-----+-----+
|       |     |     |             |       |     |     |
| Entry | foo | 123 |             | Entry | bar | 456 |
|       |     |     |             |       |     |     |
+-------+-----+-----+             +-------+-----+-----+
julien-truffaut commented 7 years ago

Good idea 👍

stanch commented 7 years ago

Ok, I will add that tonight unless you want to contribute :)

julien-truffaut commented 7 years ago

I am not sure I will have the time in the next weeks unfortunately :(

stanch commented 7 years ago

diagram

stanch commented 7 years ago

Just released 0.7.2 with these changes.

julien-truffaut commented 7 years ago

awesome, thank you!