Jump to content
  • Advertisement
Sign in to follow this  
GDKnight

Linked Lists - Sentinel nodes

This topic is 4586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was reading wikipedia about Sentinel nodes. It describes them but how exactly do they work? Does anyone have an example, just wondering for perhaps a more indepth explaination or diagram of some sort explaining a sentinel node.

Share this post


Link to post
Share on other sites
Advertisement
In general: They are nodes that mean special things.

For example:

SENTINEL -> NODE_1 -> NODE_2

This way, there is always a "head" node, the sentinel. Some lists have a tail sentinel that specifies that the end of the list has been reached. You can sort of imagine them like bookends.

Also: Not to be confused with these

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A sentinel is just a special node that is used as a marker. Usually you use it to mark a special node like 'nil'. It's just a node you have selected out to be the sentinel, which you can than test for. In C you would probably just test against the addresses of pointers to see if it was the sentinel.


if(pointer == sentinel)
{ ... }


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!