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 7405071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:20:52+00:00 2026-05-29T05:20:52+00:00

I have an interface: List<List<Integer>> separate(List<Integer> list); I want to be able to separate

  • 0

I have an interface:

List<List<Integer>> separate(List<Integer> list);

I want to be able to separate the parameterized list into separate integer lists based on if the values within the list object are the same so if the list was {1, 1, 5, 7, 9} it would create 4 separate lists:

  • {1, 1}
  • {5}
  • {7}
  • {9}

Is there an easy library to use for this? I can quite easily come up with an algorithm which does this but if the elements in the list were not Integers but Objects and you wanted to base the grouping rules on some fields within it then how would I go about doing that?

Thanks very much for any help.

  • 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-05-29T05:20:53+00:00Added an answer on May 29, 2026 at 5:20 am

    Generally you’d want to use a temporary Map<Key, List<Type>>, where Key and Type would both be Integer in your example. For each Integer in the big list, check the Map to see if that Integer is already a key. If not, then add it with a new List<Integer>. Then either way, add the Integer to the List for that key. Then at the very end, construct List<Integer> from the values() of the Map.

    For a more complicated Type, you’d choose some distinguishing data value to be the Key, but otherwise the code would be analogous.

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

Sidebar

Related Questions

I have the following method and interface: public object ProcessRules(List<IRule> rules) { foreach(IRule rule
I have an interface with a method public List< Object > getLeftBusinessObjects( List< Object
I am working on a jQuery-based todo list interface, and have hit a bit
I have a class as follows :- interface IFilterCondition { List<Name> ApplyFilter(List<Name> namesToFilter); }
Say I have this code - public interface ParentInterface1 { public List<? extends ChildInterface1>
I have two questions 1) my interface i have interface called IRegister and within
I have an interface as follows: public interface ISelectEntity { List<T> GetFromDB<T, O>(O data);
I have an interface list which stores a variety of objects derived from that
Currently I have an object implementing the IComparable interface (ASP.NET 3.5, VB). When I
I'm having problems using generics and lists with interfaces. I have an interface Comment,

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.