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

  • Home
  • SEARCH
  • 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 46403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:57:38+00:00 2026-05-10T15:57:38+00:00

Lasty, I tried to implements an hybrid structure in Java, something that looks like:

  • 0

Lasty, I tried to implements an hybrid structure in Java, something that looks like:

public class MapOfSet<K, V extends HasKey<K>> implements Set<V>, Map<K, Set<V>> 

Where HasKey is the following interface:

public interface HasKey<K> {     public K getKey(); } 

Unfortunately, there are some conflicts between methos signature of the Set interface and the Map interface in Java. I’ve finally chosen to implements only the Set interface and to add the Map method without implementing this interface.

Do you see a nicer solution?

In response to the first comments, here is my goal:

Have a set structure and be able to efficiently access to a subset of values of this set, corresponding to a given key value. At the beginning I instantiated a map and a set, but I tried to joined the two structures to optimize performances.

  • 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. 2026-05-10T15:57:38+00:00Added an answer on May 10, 2026 at 3:57 pm

    Perhaps you could add more information which operations do you really want. I guess you want to create a set which automatically groups their elements by a key, right? The question is which operations do you want to be able to have? How are elements added to the Set? Can elements be deleted by removing them from a grouped view? My proposal would be an interface like that:

    public interface GroupedSet<K, V extends HasKey<K>> extends Set<V>{     Set<V> havingKey(K k); } 

    If you want to be able to use the Set as map you can add another method

    Map<K,Set<V>> asMap(); 

    That avoids the use of multiple interface inheritance and the resulting problems.

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Create alias in your ~/.bash_profile (on the server). Changes in… May 11, 2026 at 10:03 am
  • added an answer My personal experience with programming for Silverlight is extremely limited,… May 11, 2026 at 10:03 am
  • added an answer You can use the initWithData: initializer: [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];… May 11, 2026 at 10:03 am

Related Questions

Lasty, I tried to implements an hybrid structure in Java, something that looks like:
I've tried figuring out this problem for the last 2 days with no luck.
last time I asked how to populate a data structure here . Now I
Last time I asked about the reverse process , and got some very efficient
The last cross platform desktop development I did was Java/Swing. What about flex?
Last Friday where I work, an oracle client was upgarded and our IIS server
Last week I implemented a date validation in our front end, a combination of
Last night I added a parameter to a stored procedure in a mySQL database.
Last weekend I changed webhosts for my website. The host server I was on
The last GUI programming I have done was with Visual Basic, which included objects

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.