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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:13:00+00:00 2026-06-02T03:13:00+00:00

I discovered containsAll() (a List interface method) during some coding today, and it looks

  • 0

I discovered containsAll() (a List interface method) during some coding today, and it looks pretty slick. Does anyone know how much this costs in terms of performance/iterations?

The documentation didn’t offer much in terms of that.

  • 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-02T03:13:02+00:00Added an answer on June 2, 2026 at 3:13 am
    • first, it iterates each element of the supplied collection
    • then it iterates all elements of the list and compares the current element with them using .equals(..) (Note: this is about lists, as you specified in the question. Other collections behave differently)

    So it’s O(n*m), where n and m are the sizes of both collections.

    public boolean containsAll(Collection<?> c) {
        Iterator<?> e = c.iterator();
        while (e.hasNext())
            if (!contains(e.next()))
            return false;
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I discovered very interested issue with XamDataGrid LoadCustomizations method. At start program I initialize
I discovered NHaml some days ago and it's a great project. When I try
i discovered today that Windows 7 comes with a very impressive MathPanel utility, for
Just discovered Go, and am very curious so far. I know I'm just being
This morning I discovered some strange behavior of the SmtpClient class (.net 3.5). Can't
I discovered(*) today that, depending on the server, my TSQL commands were case-sensitive, meaning
I discovered today in iReport that I cannot set the initial value expression of
I discovered to have some problem to fully understand callbacks scoping when trying to
I discovered that the source of a bug in some code I was writing
i discovered that a wxCriticalSection is not recursive ( does deadlock when a thread

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.