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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:38:08+00:00 2026-05-29T06:38:08+00:00

The java.util.LinkedList does not allow you to quickly remove a given object in the

  • 0

The java.util.LinkedList does not allow you to quickly remove a given object in the list. The remove(object) method performs a linear search to find the object in the list so it can remove it. Since this is a double linked-list, it would be nice to remove by just updating the pointers (node.prev and node.next).

What is the Java standard solution for this problem?

NOTE1: I don’t want to remove while iterating. I know that is fast, but I am not iterating through my elements in the first place.

NOTE2: To make it simple: Given an object O that I know it is in a double linked-list, I want to quickly remove O from that list (by updating the pointers) without having to linear search for it in the list, as java.util.LinkedList does.

  • 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-29T06:38:09+00:00Added an answer on May 29, 2026 at 6:38 am

    You should take a look at the LinkedHashSet class. Basically it’s a HashSet that maintains a doubly-linked list among its entries. It supports retrieval (and thus also deletion) of an element in O(1) (hopefully). Check the link for the specification on the how it handles the elements order in case of reinserting an entry and other details.

    EDIT:

    If you need to store duplicates you can take a look at the Guava LinkedHashMultiset (never used so far). The Guava user guide on Multiset is here.

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

Sidebar

Related Questions

Why is it that java.util.List does not implement Serializable while subclasses like LinkedList ,
I'm confused by the following code: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class
Given a java.util.Date object how do I go about finding what Quarter it's in?
I am using java.util.LinkedList Is there any method that helps me with this?
Why does the following java code result in an infinite loop? import java.util.LinkedList; import
In java.util.Calendar , January is defined as month 0, not month 1. Is there
The error I get is 'IllegalArgumentException occured' Can not set java.util.ArrayList field mi.types.ListOfObjects.objects to
How do I write a static method in Java that will take a List,
Let's assume we have a java.util.LinkedList containing a few hundreds of elements. One possibility
java.util.PriorityQueue allows a Comparator to be passed at construction time. When inserting elements, they

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.