Difference between revisions of "IsEmpty"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
 
Line 13: Line 13:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Pretty self explanatory, this method returns a bool indicating whether the queue instance has any values or not.
+
This section of code checks to see if the last position in the queue is empty, to determine if the queue is full or not, and thus whether more data can be added. If the position is free, the method returns true. If it is not free, the method returns false.

Latest revision as of 13:31, 14 November 2017

            public bool IsEmpty()
            {
                if (this.Rear == -1)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

This section of code checks to see if the last position in the queue is empty, to determine if the queue is full or not, and thus whether more data can be added. If the position is free, the method returns true. If it is not free, the method returns false.