Guest User

Untitled

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