Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
412 stars 48 forks source link

is_linked is badly named #63

Open przygienda opened 3 years ago

przygienda commented 3 years ago

it only checks next (even in doubly linked case).

this would be more logical has_successor or something like this

there is now no real method to figure out whether a node is really linked onto the list on not on it.

Amanieu commented 3 years ago

next contains UNLINKED_MARKER if the node is unlinked, whereas it contains 0/null when there is no next element in the list. is_linked will correctly return false for the last element in a list.

przygienda commented 3 years ago

my gripe is only with 'is_linked', this is not equivalent to 'has_next' and it's very noticeable in code on doubly linked list

On Fri, Sep 10, 2021 at 1:53 PM Amanieu @.***> wrote:

next contains UNLINKED_MARKER if the node is unlinked, whereas it contains 0/null when there is no next element in the list. is_linked will correctly return false for the last element in a list.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Amanieu/intrusive-rs/issues/63#issuecomment-916845740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANDICZEQ7IVYL7UXPFRCJLUBHWVJANCNFSM5DZFH3PQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Amanieu commented 3 years ago

I don't understand what the problem is: is_linked tells you whether a node is linked into a list. It does not tell you whether there is another node before/after this one.