Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 with Unchecked_Deallocation;
- 2
- 3 package body Generic_Queues is
- 4 -- Procedimiento para liberar nodos cuando
- 5
- 6 procedure Delete is new Unchecked_Deallocation (Queue_Node, Access_Queue_Node);
- 7
- 8 procedure Insert (Q : in out Queue; E : Element) is
- 9 X : Access_Queue_Node;
- 10 cuenta : Natural := 0;
- 11 begin
- 12 cuenta := cuenta + 1;
- 13 X := new Queue_Node;
- 14 X.Info := E;
- 15 X.Next := Null;
- 16 if Q.First = Null then
- 17 Q.First := X;
- 18 Q.Last := X;
- 19 else
- 20 X.Next := Q.First;
- 21 Q.First := X;
- 22 end if;
- 23 end Insert;
- 24
- 25 procedure Extract (Q : in out Queue) is
- 26 X : Access_Queue_Node;
- 27 begin
- 28 Q.First := X.Next;
- 29 end Extract;
- 30
- 31 function First_Element (Q : Queue) return Element is
- 32 begin
- 33 return Q.First.Info;
- 34 end First_Element;
- 35
- 36 function Count (Q : Queue) return Natural is
- 37 cuenta : Natural;
- 38 begin
- 39 return cuenta;
- 40 end Count;
- 41
- 42 end Generic_Queues;
Add Comment
Please, Sign In to add comment