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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:40:50+00:00 2026-05-27T15:40:50+00:00

Main Question: I’m seeking some way to give an object within a LinkedList a

  • 0

Main Question:
I’m seeking some way to give an object within a LinkedList a reference to itself within the list so that it can (efficiently) remove itself from said list (Without sorting through the list looking for itself. I’d like it to just directly cut itself from the list and tie the previous and next items together.).

Less Necessary Details:
I’ve done a reasonable amount of googling and not found anything other than people advising not to use circular references.

I’d like to do this as I’m designing a game, and in the game objects can implement various interfaces which allow them to be in various lists which are looped through in a prioritized manner. A single object might be in a draw loop, a loop which steps it through the frames of its animation, a high priority logic loop, and a low priority logic loop all at the same time. I would like to implement a removeFrom|TypeOfLoop| method in each appropriate interface so that if an object decides that it no longer needs to be in a loop it can directly remove itself. This keeps the objects that do the actual looping pleasantly simple.

Alternatively, If there is no way to do this, I’m thinking of implementing a flagging system where the list checks to see if each item wants to be removed based on a variable within the item. However, I dislike the idea of doing this enough to possibly just make my own LinkedList that is capable of removing by reference.

  • 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-27T15:40:51+00:00Added an answer on May 27, 2026 at 3:40 pm

    I did this recently. I was looking for an O(1) add O(1) remove lock-free Collection. Eventually I wrote my own Ring because I wanted a fixed-size container but you may find the technique I used for my first attempt of value.

    I don’t have the code in front of me but if memory serves:

    Take a copy of Doug Lea‘s excellent Concurrent Doubly LinkedList and:

    1. Expose the Node class. I used an interface but that is up to you.

    2. Change the add, offer … methods to return a Node instead of boolean. It is now no longer a java Collection, but see my comment later.

    3. Expose the delete method of the Node class or add a remove method that takes a Node.

    You can now remove elements from the list in O(1) time, and it is Lock Free.

    Added

    Here’s an implementation of the remove(Node) method taken from his Iterator implementation. Note that you have to keep trying until you succeed.

    public void remove(Node<E> n) {
      while (!n.delete() && !n.isDeleted())
        ;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Main Question: I have a reference type (object/class) where I would like to specify
My main question is given a feature centroid, how can I draw it in
first of all, my main question: What are some good troubleshooting techniques when you
Quick question, is there a way to call your main method whatever you like
Main question: I have a Form that is MDI container and placed a Splitter.
My main question is does the Threading lock object create atomic locks? It doesn't
I have found article that skims over this. But my main question is do
Main question: Is there a better way to accomplish creating a reusable control? So
The main question doesn't give the idea of the problem, so here I am
Main Question: Is there a way to insert ONE double quotation in a string

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.