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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:11:42+00:00 2026-06-11T23:11:42+00:00

Please refer to the following method : public Set<LIMSGridCell> getCellsInColumn(String columnIndex){ Map<String,LIMSGridCell> cellsMap =

  • 0

Please refer to the following method :

public Set<LIMSGridCell> getCellsInColumn(String columnIndex){
    Map<String,LIMSGridCell> cellsMap = getCellsMap();
    Set<LIMSGridCell> cells = new HashSet<LIMSGridCell>();
    Set<String> keySet = cellsMap.keySet();
    for(String key: keySet){
      if(key.startsWith(columnIndex)){
        cells.add(cellsMap.get(key));
      }
    }
    return cells;
  }

FindBugs give this waring message :

“Inefficient use of keySet iterator instead of entrySet iterator
This method accesses the value of a Map entry, using a key that was
retrieved from a keySet iterator. It is more efficient to use an
iterator on the entrySet of the map, to avoid the Map.get(key)
lookup.”

  • 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-11T23:11:43+00:00Added an answer on June 11, 2026 at 11:11 pm

    You are retrieving all the keys (accessing the whole map) and then for some keys, you access the map again to get the value.

    You can iterate over the map to get map entries (Map.Entry) (couples of keys and values) and access the map only once.

    Map.entrySet() delivers a set of Map.Entrys each one with the key and corresponding value.

    for ( Map.Entry< String, LIMSGridCell > entry : cellsMap.entrySet() ) {
        if ( entry.getKey().startsWith( columnIndex ) ) {
            cells.add( entry.getValue() );
        }
    }
    

    Note: I doubt that this will be much of an improvement since if you use map entries you will instantiate an object for each entry. I don’t know if this is really faster than calling get() and retrieving the needed reference directly.

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

Sidebar

Related Questions

I'm trying to split the following string primarily based on whitespace. Please refer to
Please refer to the following code of from the Javadoc of Future class: FutureTask<String>
Please refer to this fiddle . While scrolling down, the table cells appear in
I have a string like this: Please refer to document ABC.123.1234.1234 and document CBA.321.4321
I have question please refer the following code to understand the question. (I removed
Please refer to the following java source code : static class SynchronizedList<E> extends SynchronizedCollection<E>
Please refer following database search tutorial and advise if search methodology is safe, especially
Please refer to the following picture. I have a dataset called dsCompanyRecords and the
Hi please refer the following HTML code: <div id=content> <p> <font size='2'> <img src=something.jpg
Please refer to the following image: I wanted to group the controls like that.

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.