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...
-
A vector quantity has (a) only magnitude, (b) only direction, (c) both direction and magnitude.
-
Explore the website of the UN Global Compact initiative, at https://www.unglobalcompact.org/. Click on the heading Engage Locally, and explore some of the companies in your part of the world that...
-
An investor wishes to invest some or all of his $12.5 million in a diversified portfolio through a commercial lender. The types of investments, the expected interest per year, and the maximum allowed...
-
Question four (20mks) Explain how the following are fundamental in appraising income property A. potential gross income (16mks) B.Net operating income (4mks) Question five (20mks) Explain the theory...
-
Start with an initial string of zeros. Choose any digit of the string to flip. When a digit is flipped, its value and all those to the right switch state between 0 and 1. Given a target string of...
-
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++?
-
Differentiate between an abstract resource and a physical resource. Give two examples of each.
-
What is the a Trust game? a)You, and only you, will decide how to divide $10 between yourself and one other person. This will happen only once. You don't know who is the other person and other person...
-
Discuss the power of reasoning to help solve such issues: Is there research (or potential research) that could answer the relevant questions? What can we do to think more objectively about solutions...
-
To maximize net income, the return on the interest-bearing account would have to be greater than the net revenue from the rental property. The net revenue from the rental property is the revenue...
-
You have decided to specialize in gathering firewood while Friday has specialized in fishing. Your time allocation sliders are set to allocate all of your time to gathering firewood. Now, use the...
-
New UK Prime Minister Liz Truss is reportedly weighing up scrapping the Soft Drinks Industry Levy (more commonly known as the sugar tax), in a move that could have knock-on effects for fizzy drinks...
-
On March 31, Katherine Bertolla retires from the partnership of Bertolla, Callahan, and Khazeie. The partner capital balances are Bertolla, $34,000; Callahan, $45,000; and Khazeie, $21,000. The...
-
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...
-
Regarding the following structure answer the following questions: N 1) What is the sar? wwww olaparib (lynparza) 2)What is the quantitive estimation (principle of assay)?
-
7. Determine the Q-values of the following reaction: N+13N P+13C (Given: Rest-mass of 13N = 13.005739 u; rest-mass of 13C = 13.003355 u.) (3 marks)
-
Consider the following description for the element iron, Fe Ph Iron is a silver-white malleable ductile magnetic heavy metallic element that readily rusts in moist air to give a hydrated iron oxide....
Study smarter with the SolutionInn App