Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoolObject collections and equality #5

Open
tpietzsch opened this issue Mar 13, 2015 · 1 comment
Open

PoolObject collections and equality #5

tpietzsch opened this issue Mar 13, 2015 · 1 comment

Comments

@tpietzsch
Copy link
Contributor

Currently, for example PoolObjectList.contains(obj) checks whether an object with the same internal id as obj is contained in the list:

    public boolean contains( final Object obj )
    {
        return ( obj instanceof PoolObject )
                ? indices.contains( ( ( PoolObject< ?, ? > ) obj ).getInternalPoolIndex() )
                : false;
    }

This should work sufficiently well for now and for TrackMate3 use case but it's not really correct.
There are two problems:

  • obj might be from a different pool.
  • the equals() method of the concrete PoolObject instance might be overridden.

In both cases, contains() will do the wrong thing.

PoolObjectList.contains() is just an example of the general problem. We will have to decide on a consistent way to handle equality and then implement it everywhere...

@tinevez
Copy link
Contributor

tinevez commented Mar 13, 2015

For issue 1, we could first check if the 2 pools (the one of the list and the one of the object) are equal.
I thought that would be an easy solution, but it forbids exchanging object between pools.

  • Object is not a good name for this thing imho -

For issue 2, I see no solution. We may have to give up and say that "equality is not implemented in the same sense than for Object. That is: bby construction equality is limited to check whether the two pools are equal (the same Object) and then if the two things points to the same index in the pool. Anything else cannot be done."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants