Thread: "marker to indicate empty queue"?

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002

    "marker to indicate empty queue"?

    hey again, thanks for the help on the last post in the book i'm learning from one of the tasks it has you do is to create a queue of char. can you help me make sense of this passage: i'll paraphrase "note the loop starts at 1 . . . the first element at offset 0 was used as a marker to indicate an empty queue" what's this marker? here's the code in question, i'll attach the rest. thanks

    void c_q::mf_showq(void)
    	int x;
    		cout<<"Q is empty"<<endl;
    Last edited by blight2c; 03-14-2002 at 10:34 PM.

  2. #2
    a queue can be implemented using any container that allows the principle of first in first out. Think about using an array to implement this (although you could also use a list or something else if you want). If you start entering data at element one and keep adding each successive element at each successive index, then back is just the highest array index at which the element of the array is occupied. if the array is empty then back will be 0. If there is one element in the array, then back will be 1. If there is 101 occupied elements in the array, then back will be 101, etc. They probably chose back because it is the last element added and taken off the queue, that is it is at the back of the line.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with binary file c++
    By lucky_mutani in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2009, 09:24 AM
  2. Finding whether UCHAR is empty?
    By Witchfinder in forum C Programming
    Replies: 4
    Last Post: 04-25-2009, 10:19 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. skipping empty files using ifstream
    By bradleym83 in forum C++ Programming
    Replies: 14
    Last Post: 08-12-2005, 07:15 AM
  5. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM