Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:52:22+00:00 2026-06-05T21:52:22+00:00

I currently have a variable that looks like this: val someVal = new HashMap[Float,

  • 0

I currently have a variable that looks like this:

val someVal = new HashMap[Float, Set[String]] with MultiMap[Float, String]

Now I would like to have a hash of these hashes of the form:

val someHashOfSomeVal = new HashMap[String, HashMap[Float, Set[String]] with MultiMap[Float, String]]

In other words, I need to have a hash table (with multiple values for each key) of hash tables (with multiple values of each key). Can anyone help me with how I declare / mutate this variable?

Do I mutate it like this?someHashOfSomeVal.addBinding("someKey", someVal)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:52:24+00:00Added an answer on June 5, 2026 at 9:52 pm

    It’s unclear to me why you’d want the top-level map to have multiple values (other maps, in this case) per key, or how that would work in practice. I’ll assume that you only want MultiMap at the lower level, in which case you can use the following approach:

    import scala.collection.mutable.{ HashMap, MultiMap, Set }    
    
    class TwoLevel[A, B, C] extends HashMap[A, MultiMap[B, C]] {
      override def default(key: A) = new HashMap[B, Set[C]] with MultiMap[B, C]
      def addTriple(a: A, b: B, c: C) {
        this += a -> this(a).addBinding(b, c)
      }
    
      def lookupPair(a: A, b: B): Set[C] = this(a).getOrElse(b, Set.empty)
    }
    
    val m = new TwoLevel[String, Float, String]
    
    m.addTriple("a", 1.0F, "b")
    m.addTriple("a", 0.0F, "c")
    
    println(m.lookupPair("a", 0.0F))
    

    Which prints Set(c), as you’d expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
In my program I have currently a piece of code that looks like this
My website file structure currently looks like this: marketplace.php cats.php On marketplace.php I have
I have a collection of string in C#. My Code looks like this: string[]
I currently have a page setup like this: PHP Variable Declarations HTML header, then
I currently have a page setup like this: PHP Variable Declarations HTML header, then
I currently have a unittest.TestCase that looks like.. class test_appletrailer(unittest.TestCase): def setup(self): self.all_trailers =
I have class that looks like this: class A { public: class variables_map vm
Currently I have a bunch of HTML stored in a variable that I am
I have JSON object inside variable like this: var chessPieces = { p-w-1 :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.