Guest User

Haffman pair

a guest
Oct 20th, 2018
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. note
  2.     description: "Summary description for {PAIR}."
  3.     author: ""
  4.     date: "$Date$"
  5.     revision: "$Revision$"
  6.  
  7. class
  8.     PAIR
  9.  
  10. inherit
  11.  
  12.     COMPARABLE
  13.  
  14. create
  15.     make
  16.  
  17. feature {NONE} -- Initialization
  18.  
  19.     make (s, c: INTEGER)
  20.             -- Initialization for `Current'.
  21.         do
  22.             char := s
  23.             cnt := c
  24.             left := VOID
  25.             right := VOID
  26.         end
  27.  
  28. feature
  29.  
  30.     char: INTEGER
  31.  
  32.     cnt: INTEGER
  33.  
  34.     left: detachable PAIR
  35.  
  36.     right: detachable PAIR
  37.  
  38.     is_less alias "<" (other: like Current): BOOLEAN
  39.         do
  40.             Result := Current.cnt > other.cnt
  41.         end
  42.  
  43.     set_left (s,c: INTEGER)
  44.         local
  45.             t: PAIR
  46.         do
  47.             create t.make (s, c)
  48.             left := t
  49.         end
  50.  
  51.     set_right (s,c: INTEGER)
  52.         local
  53.             t: PAIR
  54.         do
  55.             create t.make (s, c)
  56.             right := t
  57.         end
  58.  
  59. end
RAW Paste Data