Question: Rewrite the code of Figure 7.3 in Ada, Java, or C#. Figure 7.3: template class queue { item items [max_items]; int next_free, next_full, num_items; public:
Rewrite the code of Figure 7.3 in Ada, Java, or C#.
Figure 7.3:
![template class queue { item items [max_items]; int next_free, next_full, num_items; public: queue () : next_free (0), next_full(0), num_items (0) { } bool enqueue (const item& it) { if (num_items ++num_items; items [next_free] == max_items) return false; it; next_free (next_free + 1) % max_items; return true; } bool dequeue (item*](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1606/2/2/2/2845fbd01cc4cd321606222284364.jpg)
template class queue { item items [max_items]; int next_free, next_full, num_items; public: queue () : next_free (0), next_full(0), num_items (0) { } bool enqueue (const item& it) { if (num_items ++num_items; items [next_free] == max_items) return false; it; next_free (next_free + 1) % max_items; return true; } bool dequeue (item* it) { if (num_items 0) return false; items [next_ful1); --num_items; *it = next_full = (next_full + 1) % max_items; return true; }; ... queue ready_list; queue int_queue;
Step by Step Solution
3.53 Rating (174 Votes )
There are 3 Steps involved in it
In ADA generic type Item is private MaxItems constant 100 with function Left Right Item return Boole... View full answer
Get step-by-step solutions from verified subject matter experts
