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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:56:49+00:00 2026-06-04T11:56:49+00:00

This is an odd question. But here goes. I have object X, which gets

  • 0

This is an odd question. But here goes.

I have object X, which gets inserted, in an array, in a hashtable, within another object (container object) It represents instances of X at point P in 3d space.

Sometimes I’ll want to refresh the X’s at a given P. This is simple enough – recall the point P from the table and manipulate the array directly.

Now say that those X’s are part of a Y – fragments of a Y to be precise. Let’s say a given Y goes away. Now, if Y goes away all X’s that are attached to it should go away as well, right?

To be precise, object Y is being removed conceptually from the model. Whether it is actually deleted or not is immaterial (it might get stored somewhere else, for instance.) But the salient point is, aside from checking every point in vicinity of Y for its X’s, how do I properly remove them from the hashtable?

  1. They’re part of an array, so another Y’s X’s will likely be there too, so we need to remove just the X’s which belong to the given Y.
  2. We can search the hashtable structure for the X’s that belong to Y – for instance we can figure out all of the points P that Y would occupy, and then pull out those containers and remove all of the X’s that are attached to our Y.
  3. Can we remove them directly? If Y has a list of its X’s, can they be removed by reference, without having to go through the effort of searching the table?

This is actually a general question about references as a whole. There are other situations where more than one reference to an object exists, and I would like to be able to remove that object quickly without having to navigate to it in its other locations.

This means that when one referencing class removes the object, the object should be ‘removed’ universally; none of the other lists should retain reference to it.

  • 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-04T11:56:51+00:00Added an answer on June 4, 2026 at 11:56 am

    In Java this problem is often addressed with WeakReference<T> objects: if you do not want a reference to prevent an object X from being collected, make it a WeakReference<X>: Java will null it out when X is no longer strongly referenced from anywhere else.

    For example, you can make a List<X> that keeps all objects that are alive, and make all other references to X weak. When an object is removed from the list and its last strong reference is gone, it becomes collectable regardless of the number of weak references to it. The obvious downside is that you need to pay attention to nulls before dereferencing each weak reference. At this point, Java does all reference tracking for you; all you need to do is to clean out the weak references that went null, which is much easier than searching through a large number of lists.

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

Sidebar

Related Questions

An odd question this will be, but here goes. I have a page on
I guess this is kind of an odd question but I have tried setting
Odd question but here it goes. I would like to set up multiple arrays
This may seem like an odd question but I was talking to a friend
This might sound a bit of an odd question but I know what I
This will be probable quite odd question. But i thought I will give it
This might be a little bit odd question, but Im trying to figure out
This may seem like an odd question, but I need to find a closed-source
This question has been asked on here a few times, but none of the
Odd question here not really code but logic,hope its ok to post it here,here

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.