From: niewiap@widzew.net (Pawe� Niewiadomski)
Subject: Modular types inside records
Date: 2000/10/21
Date: 2000-10-21T10:27:49+00:00 [thread overview]
Message-ID: <8FD47616EPablo@213.25.200.9> (raw)
I have an assignment to implement a normal, unidirectional queue as a
static array of n_max elements. I wanted the array to be "cyclic", namely
I wanted to use two variables: head and tail of a modular type within the
queue record so that there would be no constraint error unless the array
were really full (checked by an appropriate function). If the tail index
were on the last element of the array, its value after the incrementation
would be 0, and by that time the 0 element of the array would be probably
freed.
generic
type item_type is private;
package queues is
type queue(n_max: positive) is tagged private;
function empty (q: queue) return boolean;
function full (q: queue) return boolean;
procedure add (q: queue; item: in item_type);
procedure remove (q: queue; item: out item_type);
private
type arr is array (natural range <>) of item_type;
type queue (n_max: positive) is tagged record
values: arr (0..n_max);
tail: natural:=0; --I want these two be of modular type with
head: natural:=1; --a modulus equal to n_max+1
end record;
end queues;
If you have any idea on how to solve this problem (no dynamic memory
allocation, please) I would be grateful for sharing it with me
Pawel
next reply other threads:[~2000-10-21 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-21 0:00 Pawe� Niewiadomski [this message]
2000-10-21 0:00 ` Modular types inside records Robert Dewar
2000-10-21 0:00 ` Pawe� Niewiadomski
2000-10-21 0:00 ` Jeff Carter
2000-10-21 0:00 ` Pawe� Niewiadomski
2000-10-23 0:00 ` Robert A Duff
2000-10-23 0:00 ` Pawe� Niewiadomski
2000-10-24 0:00 ` Robert A Duff
2000-10-25 1:50 ` Nick Roberts
2000-10-25 0:00 ` Pawe� Niewiadomski
2000-10-27 22:05 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox