Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 1.72 KB | None | 0 0
  1. --
  2. --  Copyright (c) 2010, Edward O'Callaghan
  3. --
  4. --  Permission to use, copy, modify, and/or distribute this software for any
  5. --  purpose with or without fee is hereby granted, provided that the above
  6. --  copyright notice and this permission notice appear in all copies.
  7. --
  8. --  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. --  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. --  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. --  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. --  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. --  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. --  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. --
  16.  
  17. --
  18. --  SPARK Verified Ada2005 Red-Back Tree in-memory implementation.
  19.  
  20. generic
  21.    type Element_Type is private;
  22.  
  23. package RB_Tree is
  24.    type Node_Type is limited private;
  25.  
  26.    procedure Insert (Tree : in out Node_Type; Element : in Element_Type);
  27.    --# derives Tree from *, Element;
  28.  
  29.    procedure Delete (Tree : in out Node_Type; Node : in Node_Type);
  30.    --# derives Tree from *, Node;
  31.  
  32.    procedure Search
  33.      (Tree    : in Node_Type;
  34.       Element : in Element_Type;
  35.       Found   : out Boolean;
  36.       Node    : out Node_Type);
  37.    --# derives Found, Node from
  38.    --#  Tree, Element;
  39.    --# post Found -> Tree (Node) = Element;
  40.    --  If Found is False then Position is undefined.
  41.  
  42. private
  43.    type Node_Colour is (Red, Black);
  44.  
  45.    type Node_Type is record
  46.       Colour      : Node_Colour      := Black;
  47.       Parent      : access Node_Type := null;
  48.       Right, Left : access Node_Type := null;
  49.    end record;
  50. end RB_Tree;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement