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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:59:09+00:00 2026-06-07T05:59:09+00:00

I have a code displayed below and its just working fine. But I was

  • 0

I have a code displayed below and its just working fine. But I was wondering if there are other ways to implement this? Basically what I am doing with 4 loops is to compare and assign a new value to Key of CopyMatrix which is a linkedhashmap inside an arraylist if a match is found using the String/Element in SeqGenerate. I had another solution which is also a loop but it wasn’t working so am stuck with this one and am wondering if there are other ways to do this with a fewer loops or maybe some other techniques.

ArrayList<ArrayList<String>> SeqGenerate = new ArrayList<ArrayList<String>>();
ArrayList<LinkedHashMap<String, Double>> copyOfMatrix = new ArrayList<LinkedHashMap<String, DOuble>>();
ArrayList<LinkedHashMap<String, Double>> calcLogProb = new ArrayList<LinkedHashMap<String, DOuble>>();


for (ArrayList<String> getArray: SeqGenerate){
            LinkedHashMap<String, Double> tempVal = new LinkedHashMap<String, Double>();
            for (String getString: getArray){
                for (LinkedHashMap<String, Double> entries: copyOfMatrix){

                    Iterator <String> iterKey = entries.keySet().iterator();
                    Iterator <Double> iterVal = entries.values().iterator();
                        while (iterKey.hasNext()){
                            String keyVal = iterKey.next();
                            Double Value = iterVal.next();

                            if (getString.equals(keyVal)){
                                Double temp = Value;
                                if (temp==0){
                                        temp=0.00000001;
                                    }

                                Double seqVal = Math.abs(Math.log10(temp));                         
                                tempVal.put(keyVal, seqVal);
                            }

                        }   
                }
            }
            calcLogProb.add(tempVal);
        }

EDIT

ok what am trying do is like this:
SeqGenerate contains this elements

ArrayList ——– String
(1)Hello World = { He el ll lo o_ _W Wo or rl ld}

(2)Hello Earth = { He el ll lo o_ _E Ea ar rt th}

Hello World and Hello Earth are an example of type of text contained in SeqGenerate but they are stored as two character sequence as I have illustrated.
copyOfMatrix contains the same kind of sequence but i generated it from another set of sentences and texts but they’re always a sequence of two characters that am going to compare and replace the value if a match is found.

So the only I know how to compare elements in nested loops is to make for loops so for example am going to compare seqGenerate element 0 element 1 to the keys stored in copy matrix. If i found a match am going to replace the value. Hope this is clear enough.

Thanks for your time!

  • 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-07T05:59:11+00:00Added an answer on June 7, 2026 at 5:59 am

    I really don’t understand why you’re doing

    Iterator <String> iterKey = entries.keySet().iterator();
    Iterator <Double> iterVal = entries.values().iterator();
    while (iterKey.hasNext()){
      String keyVal = iterKey.next();
      Double Value = iterVal.next();
    
      if (getString.equals(keyVal)){
        Double temp = Value;
        if (temp==0){
          temp=0.00000001;
        }
    
        Double seqVal = Math.abs(Math.log10(temp));                         
        tempVal.put(keyVal, seqVal);
      }
    }
    

    The whole point of a Map is to avoid linear-time traversals. This should just be

    Double temp = entries.get(getString);
    if (temp != null) {
      if (temp.doubleValue() == 0) {
        temp = 0.00000001;
      }
      tempVal.put(getString, Math.abs(Math.log10(temp));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried using the code below but it only display results in Chrome
I have this code for a select box which is being displayed by the
I'm a EE newbie. I have the code below. the poll weblog displays at
I have displayed the map in my app by using the following code. I
I have this code: def display(self): print self.doc.toprettyxml(indent= ) strigName ='/Users/my_user/Desktop/python/' + str(datetime.datetime.now()) +
I have this code to display the data retrieved from DB in accounts_view.php :
I have people inserting video code to be displayed on my website. I want
I'm ripping my noob hair out here. Can't understand why below code isn't working.
I have a UIView (menuView in code below) of size 320x218 inside a view.
For some reason, this is happening very vaguely. Its working sometimes and sometimes it

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.