Details

      Description

      Obtaining 'values' from range view of TreeMap returns all values from original map.

      val tm: mutable.TreeMap[String, String] = mutable.TreeMap[String, String]()
      tm.put("a", "a")
      tm.put("b", "b")
      tm.put("c", "c")
      tm.put("d", "d")
       
      println(s"scala: ${tm.range("b", "c").values.mkString(",")}")
       
      val jtm = new util.TreeMap[String, String]()
      jtm.put("a", "a")
      jtm.put("b", "b")
      jtm.put("c", "c")
      jtm.put("d", "d")
       
      println(s"java: ${
      jtm.subMap("b", "c")
              .values()
              .stream()
              .collect(Collectors.joining(","))
          }")
      

      Output:
      scala: a,b,c,d
      java: b

      Also keySet for mutable.TreeSet works properly on range but for mutable.TreeMap - does not

      val tm: mutable.TreeMap[String, String] = mutable.TreeMap[String, String]()
      tm.put("a", "a")
      tm.put("b", "b")
      tm.put("c", "c")
      tm.put("d", "d")
       
      println(s"treeMap: ${tm.range("b", "c").keySet.mkString(",")}")
       
      val ts: mutable.TreeSet[String] = mutable.TreeSet[String]()
      ts.add("a")
      ts.add("b")
      ts.add("c")
      ts.add("d")
       
      println(s"treeSet: ${ts.range("b", "c").keySet.mkString(",")}")
      
      

      Output:
      treeMap: a,b,c,d
      treeSet: b

        Attachments

          Activity

            People

            • Assignee:
              ichaki5748 Evgeny Slutsky
              Reporter:
              ichaki5748 Evgeny Slutsky
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: