/tutorial/backtracking/logigram/permut.e

http://github.com/tybor/Liberty · Specman e · 49 lines · 27 code · 4 blank · 18 comment · 2 complexity · c18837731dae7ac9b1a60845e4b7cb67 MD5 · raw file

  1. -- See the Copyright notice at the end of this file.
  2. --
  3. class PERMUT
  4. inherit
  5. COMPARABLE
  6. undefine copy, is_equal, fill_tagged_out_memory
  7. end
  8. FAST_ARRAY[INTEGER]
  9. creation {ANY}
  10. make, from_collection
  11. feature {ANY}
  12. infix "<" (other: like Current): BOOLEAN is
  13. local
  14. i: INTEGER; up: INTEGER
  15. do
  16. from
  17. up := upper.min(other.upper)
  18. until
  19. i > up or else item(i) /= other.item(i)
  20. loop
  21. i := i + 1
  22. end
  23. if i <= up then
  24. Result := item(i) < other.item(i)
  25. else
  26. Result := i <= other.upper
  27. end
  28. end
  29. end -- class PERMUT
  30. --
  31. -- ------------------------------------------------------------------------------------------------------------------------------
  32. -- Copyright notice below. Please read.
  33. --
  34. -- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
  35. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  36. -- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
  37. -- You are allowed to redistribute it and sell it, alone or as a part of another product.
  38. --
  39. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  40. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  41. --
  42. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  43. --
  44. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  45. -- ------------------------------------------------------------------------------------------------------------------------------