Write a package body for the list abstraction of Figure 10.2. Figure 10.2 generic type item is
Question:
Write a package body for the list abstraction of Figure 10.2.
Figure 10.2
Transcribed Image Text:
generic type item is private; default_value : item; Ada supports both type -- and value generic parameters -- package g_list is list_err : exception; type list_node is tagged private; 'tagged' means extendable; 'private' means opaque -- type list_node_ptr is access all list_node; 'all' means that this can point at 'aliased' nonheap data procedure initialize(self : access list_node; v : item := default_value); 'val' will get default value if second parameter is not provided -- --- procedure finalize(self : access list_node); function get_val (self : access list_node) return item; function predecessor (self : access list_node) return list_node_ptr; function successor (self : access list_node) return list_node_ptr; function singleton(self : access list_node) return boolean; procedure insert_before (self : access list_node; new_node : list_node_ptr); procedure remove (self : access list_node); type list is tagged private; type list_ptr is access all list; procedure initialize(self : access list); procedure finalize(self : access list); function empty(self : access list) return boolean; function head (self : access list) return list_node_ptr; procedure append (self : access list; new_node : list_node_ptr); private type list_node is tagged record prev, next, head_node : list_node_ptr; val : item; end record3; type list is tagged record head_node : aliased list_node; -- 'aliased' means that an 'all' pointer can refer to this end record; end g_list; ... package body g_list is definitions of subroutines -- ... end g_list;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 81% (11 reviews)
ANSWER package body GList is definitions of subroutines procedure InitializeSelf access ListNode V I...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
FILL IN THE BLANKS: A) For a relation to be a FUNCTION, a B) For a relation to have an INVERSE that is a function, a than one point. C) For a relation to be one-to-one (it is both a function and has...
-
Attached are two data sets, one concerning Skittles and one about cereals. You may assume both samples provided were selected randomly and are representative of the population. Be sure to use the...
-
For the square two-dimensional body shown in Figure P13-21, determine the temperature distribution. Let Kxx = Kyy = 25 Btu / (h-ft-oF) and h = 10 Btu / (h-ft2 -oF). Convection occurs across side 4-5....
-
The ABC Company has a cost of equity of 24.76 percent, a before-tax cost of debt of 5.37 percent, and a tax rate of 26 percent. What is the firm's weighted average cost of capital if the proportion...
-
Repeat Problem 4.25 for reach lengths of 6, 12, and 32 km. What happens to the timing and value of the peak flow? Explain. In problem 4.25 Using only the inflow hydrograph from Example 4.7 (i.e., no...
-
Provide an example instance of the fractional knapsack problem where a greedy strategy based on repeatedly choosing as much of the highest-benefit item as possible results in a suboptimal solution.
-
Terrific Tiles Ltd has a policy of maintaining a finished goods inventory balance at the end of a month equal to 50% of the sales requirements of the following month. The ending inventory balance on...
-
The management of Morales Co. is reevaluating the appropriateness of using its present inventory cost flow method, which is average-cost. They request your help in determining the results of...
-
Stefney Christian Date: 06/26/2023 To: From: New England Patriot Subject: Analysis of Aircraft Purchase vs. Chartering Decision I've done a thorough analysis of the decision to buy or charter a plane...
-
The following relations keep track of airline flight information: Flights (flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time, price: real) Aircraft (aid:...
-
Rewrite the list and queue abstractions in Eiffel, Java, and/or C#.
-
Can you emulate the inner class of Example 10.22 in C# or C++?
-
Some organizations purposefully select a CIO that has strong business management backgrounds, not just technical experience. Under what organizational circumstances do you think this might be an...
-
How have your interviews for jobs, clubs, or other organizations gone in the past? How would you describe your comfort level? What were your strengths, and in what ways did you fall short? Describe...
-
After you incorporate feedback on your generic resume, revise your resume for a particular job. Find a job posting that interests you and tailor your experience and other information to fit that...
-
To prepare for a presentation, imagine different audiences. In small groups, describe how you would identify audiences that are hostile, skeptical, or laid-back. Try to be specific about their body...
-
How do you feel about your resumeyour present one and the prospect of updating it? When you read it, what makes you feel proud? What makes you feel sad, worried, or inadequate? Try to reframe your...
-
To what extent are you anxious or excited about giving presentations? In what situations are you more comfortable, and in what situations are you more nervous? How do you think your reaction compares...
-
Seneca Co. began year 2016 with 6,500 units of product in its January 1 inventory costing $35 each. It made successive purchases of its product in year 2016 as follows. The company uses a periodic...
-
Find the image of x = k = const under w = 1/z. Use formulas similar to those in Example 1. y| y = 0 -21 -2 -1 -1, /1 12 T -1 -1 y= -2 x =0
-
Dr. Amongus claims that the order in which a fixed set of entries is inserted into a binary search tree does not matterthe same tree results every time. Give a small example that proves he is wrong.
-
How many different binary search trees can store the keys {1,2,3}?
-
Describe an efficient multimap structure for storing n entries whose r < n keys have distinct hash codes. Your structure should perform operation getAll in O(1 +s) expected time, where s is the...
-
With regard to the production possibilities frontier (PPF), an efficient point is a point that is: ?
-
Within the context of rapidly evolving regulatory landscapes and heightened ethical scrutiny, how do advanced organizations navigate the ethical complexities of technological innovation and...
-
Write a program that accepts an integer limit and an integer value and that prints a complete line of output reporting the multiples of value uptil the limit . Keep prompting the user for a value...
Study smarter with the SolutionInn App