Standard library: Containers
Simple todo list
Goal: implement a simple to-do list system using vectors.
Steps:
Implement the
Todo_Lists
package.
Declare the
Todo_Item
type.Declare the
Todo_List
type.Implement the
Add
procedure.Implement the
Display
procedure.
Todo_Item
type is used to store to-do items.
It should be implemented as an access type to strings.
Todo_List
type is the container for all to-do items.
It should be implemented as a vector.
Procedure
Add
adds items (ofTodo_Item
type) to the list (ofTodo_List
type).
This requires allocating a string for the access type.
Procedure
Display
is used to display all to-do items.
It must display one item per line.
Remarks:
This exercise is based on the Simple todo list exercise from the More About Types.
Your goal is to rewrite that exercise using vectors instead of arrays.
You may reuse the code you've already implemented as a starting point.
List of unique integers
Goal: create function that removes duplicates from and orders a collection of elements.
Steps:
Implement package
Ops
.
Declare the
Int_Array
type.Declare the
Integer_Sets
type.Implement the
Get_Unique
function that returns a set.Implement the
Get_Unique
function that returns an array of integer values.
Requirements:
The
Int_Array
type is an unconstrained array of positive range.The
Integer_Sets
package is an instantiation of theOrdered_Sets
package for theInteger
type.The
Get_Unique
function must remove duplicates from an input array of integer values and order the elements.
For example:
if the input array contains
(7, 7, 1)
the function must return
(1, 7)
.You must implement this function by using sets from the
Ordered_Sets
package.
Get_Unique
must be implemented in two versions:
one version that returns a set —
Set
type from theOrdered_Sets
package.one version that returns an array of integer values —
Int_Array
type.
Remarks:
Sets — as the one found in the generic
Ordered_Sets
package — are useful for quickly and easily creating an algorithm that removes duplicates from a list of elements.