On a queue, which end is the "head"?

Posted by Aidan Cully on Programmers See other posts from Programmers or by Aidan Cully
Published on 2012-04-14T21:05:12Z Indexed on 2012/04/14 23:45 UTC
Read the original article Hit count: 331

Filed under:

I had always thought that the "head" of a queue as the next element to be read, and never really questioned that usage. So a linked-list library I wrote, which is used for maintaining queues, codified that terminology: we have a list1_head macro that retrieves the first element; when using this library in a queue, this will be the first element to be removed.

But a new developer on the team was used to having queues implemented the other way around. He described a queue as behaving like a dog: you insert at the head, and remove at the tail. This is a clever enough description that I feel like his usage must be more widespread, and I don't have a similarly evocative description of my preferred usage.

So, I guess, there are two related questions: 1, what does the "head" of a queue mean to you? and 2, why do we use the word "head" to describe that concept?

© Programmers or respective owner

Related posts about terminology