Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Queue-Definition/Elisa/queue-definition-1.elisa
Normal file
23
Task/Queue-Definition/Elisa/queue-definition-1.elisa
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
component GenericQueue ( Queue, Element );
|
||||
type Queue;
|
||||
Queue (MaxLength = integer) -> Queue;
|
||||
Length( Queue ) -> integer;
|
||||
Empty ( Queue ) -> boolean;
|
||||
Full ( Queue ) -> boolean;
|
||||
Push ( Queue, Element) -> nothing;
|
||||
Pull ( Queue ) -> Element;
|
||||
begin
|
||||
Queue (MaxLength) = Queue:[ MaxLength; length:=0; list=alist(Element) ];
|
||||
Length ( queue ) = queue.length;
|
||||
Empty ( queue ) = (queue.length <= 0);
|
||||
Full ( queue ) = (queue.length >= queue.MaxLength);
|
||||
|
||||
Push ( queue, element ) =
|
||||
[ exception (Full(queue), "Queue Overflow");
|
||||
queue.length:= queue.length + 1;
|
||||
add (queue.list, element)];
|
||||
Pull ( queue ) =
|
||||
[ exception (Empty(queue), "Queue Underflow");
|
||||
queue.length:= queue.length - 1;
|
||||
remove(first(queue.list))];
|
||||
end component GenericQueue;
|
||||
29
Task/Queue-Definition/Elisa/queue-definition-2.elisa
Normal file
29
Task/Queue-Definition/Elisa/queue-definition-2.elisa
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use GenericQueue (QueueofPersons, Person);
|
||||
type Person = text;
|
||||
Q = QueueofPersons(25);
|
||||
|
||||
Push (Q, "Peter");
|
||||
Push (Q, "Alice");
|
||||
Push (Q, "Edward");
|
||||
Q?
|
||||
QueueofPersons:[MaxLength = 25;
|
||||
length = 3;
|
||||
list = { "Peter",
|
||||
"Alice",
|
||||
"Edward"}]
|
||||
Pull (Q)?
|
||||
"Peter"
|
||||
|
||||
Pull (Q)?
|
||||
"Alice"
|
||||
|
||||
Pull (Q)?
|
||||
"Edward"
|
||||
|
||||
Q?
|
||||
QueueofPersons:[MaxLength = 25;
|
||||
length = 0;
|
||||
list = { }]
|
||||
|
||||
Pull (Q)?
|
||||
***** Exception: Queue Underflow
|
||||
Loading…
Add table
Add a link
Reference in a new issue