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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:28:50+00:00 2026-05-26T00:28:50+00:00

Is this possible? I have a function which accepts a user string and then

  • 0

Is this possible?

I have a function which accepts a user string and then splits into an array of words. I’m going to sort the array and de-duplicate it.

However, it will be used in a function which is called in an iterative step. It actually iterates over a database and checks for each word in the user defines string in each field.

I would like to only sort and de-dup the array once but call the function many for that particular instance of the class. Should I just store the sorted array in a static instance variable?

Thanks for your time


My code is something like this (pseudo-code):

  public class searchAssistant{
        private float mScores[][];
        private Cursor mCursor; 

        public searchAssistant(Cursor c){
            mCursor = c; 
        }

        private float scoreType1(String typeFromCursor, String typeFromUser){
             if (typeFromCursor == typeFromUser) {return 1}
             else {return 0}

        }

       //similar method for type scoreType2 but sorting an array



       private int[] scoreAll(){
          int 1 = 0; 

         do {
             mScores = ScoreType1(mCursor.getString(), smomeString) + scoreType2(...);
              itr++;
            } while(cursor.moveToNext)
            return mScores;
       }

 }

is this the wrong way to be doing things?

  • 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-26T00:28:50+00:00Added an answer on May 26, 2026 at 12:28 am

    No. Change the signature of the method called multiple times to make it accept the array, and compute the array before calling the method:

    Instead of

    String s = "...";
    while (someCondition) {
        someMethodCalledMultipleTimes(s);
    }
    

    Use something like this:

    String s = "...";
    String[] array = computeTheArrayFormTheString(s);
    while (someCondition) {
        someMethodCalledMultipleTimes(array);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible? I want to have the To:, Body, and an Attachment all
Surely this is possible? I have been hunting through PyQt tutorials and documentation but
Whether this is possible I don't know, but it would mighty useful! I have
I'm wondering if this is possible in SQL. Say you have two tables A
I cannot understand how this is possible. Please help!! I have an app with
This question is about App domains and Sessions. Is it possible to have IIS
In particular, would it be possible to have code similar to this c++ code
I'm not sure if this is even possible but here goes: Currently I have
This is probably not possible, but I have this class: public class Metadata<DataType> where
Is it possible to define a spring-managed EJB3 hibernate listener? I have this definition

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.