Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4294

Collection and Map functions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.7.3
    • 1.8-beta-1
    • groovy-jdk
    • None
    • Patch

    Description

      This improvement adds the following methods to Set:

      union - for completeness, a synonym for plus (to match intersect)

      This improvement adds the following methods to Map:

      Set domain() - a synonym for keySet
      Set codomain() - returns a set of unique values
      Set range() - a synonym for codomain
      Map domainRestrict(Set s) - returns a map of those entries whose keys appear in set s
      Map rangeRestrict(Set s) - returns a map of those entries whose values appear in set s
      Set image(Set s) - returns a set of unique values of a map whose domain appears in set s. Note image is equivalent to map.domainRestrict(s).range()
      Map invert(Map m) - returns a map with the key value relationship inverted.

      Attachments

        1. groovy4294_dgm_map_set_methods.patch
          19 kB
          Paul King
        2. MapAndSetTest.groovy
          2 kB
          Brad Long
        3. patchfile.txt
          8 kB
          Brad Long

        Activity

          People

            paulk Paul King
            chiron Brad Long
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: