Commons Collections
  1. Commons Collections
  2. COLLECTIONS-152

Implementation of SynchronizedBidiMap and SynchronizedMap, with tests

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.x
    • Component/s: BidiMap
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      I've implemented SynchronizedBidiMap which was listed in the task list for
      Commons Collections. Implementing this required that I also implement
      SynchronizedMap. As usual, I tried to keep the format of the code similar to
      other code in Commons Collections. I've also included JUnit tests for both of
      these new classes and have included the .obj files suitable for placement in
      data/test so you don't have to bother generating them yourself.

        Activity

        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12137)
        SynchronizedBidiMap.java - Implementation

        Show
        Eric Crampton added a comment - Created an attachment (id=12137) SynchronizedBidiMap.java - Implementation
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12138)
        SynchronizedMap.java - Implementation

        Show
        Eric Crampton added a comment - Created an attachment (id=12138) SynchronizedMap.java - Implementation
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12139)
        TestSynchronizedBidiMap.java - Tests

        Show
        Eric Crampton added a comment - Created an attachment (id=12139) TestSynchronizedBidiMap.java - Tests
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12140)
        TestSynchronizedMap.java - Tests

        Show
        Eric Crampton added a comment - Created an attachment (id=12140) TestSynchronizedMap.java - Tests
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12141)
        SynchronizedBidiMap.emptyCollection.version3.obj - Test serialization file

        Show
        Eric Crampton added a comment - Created an attachment (id=12141) SynchronizedBidiMap.emptyCollection.version3.obj - Test serialization file
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12142)
        SynchronizedBidiMap.fullCollection.version3.obj - Test serialization file

        Show
        Eric Crampton added a comment - Created an attachment (id=12142) SynchronizedBidiMap.fullCollection.version3.obj - Test serialization file
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12143)
        SynchronizedMap.emptyCollection.version3.2.obj - Test serialization file

        Show
        Eric Crampton added a comment - Created an attachment (id=12143) SynchronizedMap.emptyCollection.version3.2.obj - Test serialization file
        Hide
        Eric Crampton added a comment -

        Created an attachment (id=12144)
        SynchronizedMap.fullCollection.version3.2.obj - Test serialization file

        Show
        Eric Crampton added a comment - Created an attachment (id=12144) SynchronizedMap.fullCollection.version3.2.obj - Test serialization file
        Hide
        Stephen Colebourne added a comment -

        I believe that there are a nunber of holes in the implementations here.

        Firstly, SychronizedMap does not seem to synchronize on the lock.

        Secondly, both SyncMap and SyncBidiMap do not create synchronized version of
        the keySet/values/entrySet(very tricky)/inverseBidiMap

        See Collections.synchronizedMap code to see how complex it gets....

        Show
        Stephen Colebourne added a comment - I believe that there are a nunber of holes in the implementations here. Firstly, SychronizedMap does not seem to synchronize on the lock. Secondly, both SyncMap and SyncBidiMap do not create synchronized version of the keySet/values/entrySet(very tricky)/inverseBidiMap See Collections.synchronizedMap code to see how complex it gets....
        Hide
        Eric Crampton added a comment -

        Ah, those are embarrassing mistakes. I'll try to fix it up early this week and
        reattach. Thanks!

        Show
        Eric Crampton added a comment - Ah, those are embarrassing mistakes. I'll try to fix it up early this week and reattach. Thanks!
        Hide
        Eric Crampton added a comment -

        Stephen, I think I've addressed your comments. But, there is one remaining
        problem: I'm trying to get the inverseBidiMap() function to work properly such
        that assertSame(bidimap, bidimap.inverseBidiMap().inverseBidiMap()) works.

        I see that TreeBidiMap does this by using the View, Inverse, and EntryView
        static/inner classes. Obviously, I don't want to have to recreate nearly similar
        classes that do the same thing for SynchronizedBidiMap.

        Any ideas on how best you'd like to see this problem solved?

        Show
        Eric Crampton added a comment - Stephen, I think I've addressed your comments. But, there is one remaining problem: I'm trying to get the inverseBidiMap() function to work properly such that assertSame(bidimap, bidimap.inverseBidiMap().inverseBidiMap()) works. I see that TreeBidiMap does this by using the View, Inverse, and EntryView static/inner classes. Obviously, I don't want to have to recreate nearly similar classes that do the same thing for SynchronizedBidiMap. Any ideas on how best you'd like to see this problem solved?
        Hide
        Stephen Colebourne added a comment -

        See UnmodifiableSortedBidiMap - you have to hold an instance variable in the
        decorator.

        Show
        Stephen Colebourne added a comment - See UnmodifiableSortedBidiMap - you have to hold an instance variable in the decorator.

          People

          • Assignee:
            Unassigned
            Reporter:
            Eric Crampton
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development