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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:44:23+00:00 2026-05-15T11:44:23+00:00

I have a huge array list which contains 1000 entries out of which one

  • 0

I have a huge array list which contains 1000 entries out of which one of the entry is “world”. And, I have a word “big world”. I want to get the word “big world” matched with “world” in the arraylist.

What is the most cost effective way of doing it? I cannot use .contains method of array list, and If I traverse all the 1000 entries and match them by pattern its going to be very costly in terms of performance. I am using Java for this.

Could you please let me know what is the best way for this?

Cheers,
J

  • 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-15T11:44:24+00:00Added an answer on May 15, 2026 at 11:44 am

    You can split up every single element of the ArrayList into words and stop as soon as you find one of them.

    I suppose by your profile you develop in Java, with Lucene you would easily do something like that

    public class NodesAnalyzer extends Analyzer {   
        public TokenStream tokenStream(String fieldName, Reader reader) {
    
            Tokenizer tokenizer = new StandardTokenizer(reader)
            TokenFilter lowerCaseFilter = new LowerCaseFilter(tokenizer)
            TokenFilter stopFilter = new StopFilter(lowerCaseFilter, Data.stopWords.collect{ it.text } as String[])
            SnowballFilter snowballFilter = new SnowballFilter(stopFilter, new org.tartarus.snowball.ext.ItalianStemmer())
    
            return snowballFilter
        }   
    }
    
        Analyzer analyzer = new NodesAnalyzer()
    
        TokenStream ts = analyzer.tokenStream(null, new StringReader(str)); 
        Token token = ts.next()
    
        while (token != null) {
           String cur = token.term()
           token = ts.next();
        }
    

    Note: this is Groovy code that I copied from a personal project so you will have to translate things like Data.stopWords.collect{ it.text } as String[] to use with plain Java

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

Sidebar

Related Questions

I have a huge text file which I want to explode into an array.
I have huge list (200000) of strings (multi word). I want to group these
I have a huge array, which I loop with a foreach. foreach ($items as
I have huge amount of txt files which contains 64x64 matrices consisting of integers.
I have one huge array and I'm trying to create an animation effect. My
I have a huge list of stores name in (.doc) file and I want
I have an array which I want to sort using some custom logic. new
So basically I have a huge array of arrays (only a 2-d array)... My
I have a huge global array of structures. Some regions of the array are
I have huge data which is static. I need to save it within the

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.