iteration.h
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:3k
开发平台:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  iteration.h
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #ifndef LEDA_ITERATION_H
  12. #define LEDA_ITERATION_H
  13. //------------------------------------------------------------------------------
  14. //   forall_items(it,...)
  15. //------------------------------------------------------------------------------
  16. #define forall_items(x,S)
  17. for(x = (S).first_item(); x; x = (S).next_item(x) )
  18. //------------------------------------------------------------------------------
  19. //   forall(x,...)
  20. //   Forall(x,...)
  21. //   forall_defined(x,...)
  22. //------------------------------------------------------------------------------
  23. // As long as the new scoping rules are not supported we avoid multiple 
  24. // declarations of the forall-loop variable by placing it in the else 
  25. // part of a dummy if-statement. However, even this does not work with some 
  26. // compilers (ztc, HP C++).
  27.   
  28. #if defined(__NEW_SCOPE_RULES__)
  29. #define forall(x,S)
  30. for(GenPtr forall_loop_item = (S).first_item();
  31. (S).forall_loop_test(forall_loop_item,x);
  32. (S).loop_to_succ(forall_loop_item))
  33. #define Forall(x,S)
  34. for(GenPtr forall_loop_item = (S).last_item();
  35. (S).forall_loop_test(forall_loop_item,x);
  36. (S).loop_to_pred(forall_loop_item))
  37. #define forall_defined(x,S)
  38. for (GenPtr forall_loop_item = (S).first_item();
  39. (S).forall_defined_test(forall_loop_item,x);
  40. (S).loop_to_succ(forall_loop_item))
  41. #else
  42. #if !defined(__ELSE_SCOPE_BUG__)
  43. #define forall(x,S)
  44. if (0); else 
  45. for(GenPtr forall_loop_item = (S).first_item();
  46. (S).forall_loop_test(forall_loop_item,x);
  47. (S).loop_to_succ(forall_loop_item))
  48. #define Forall(x,S)
  49. if (0); else 
  50. for(GenPtr forall_loop_item = (S).last_item();
  51. (S).forall_loop_test(forall_loop_item,x);
  52. (S).loop_to_pred(forall_loop_item))
  53. #define forall_defined(x,S)
  54. if (0); else 
  55. for (GenPtr forall_loop_item = (S).first_item();
  56. (S).forall_defined_test(forall_loop_item,x);
  57. (S).loop_to_succ(forall_loop_item))
  58. #else
  59. #define forall(x,S)
  60. for((S).Forall_Loop_Item()=(S).first_item();
  61. (S).forall_loop_test((S).Forall_Loop_Item(),x);
  62. (S).loop_to_succ((S).Forall_Loop_Item()))
  63. #define Forall(x,S)
  64. for((S).Forall_Loop_Item()=(S).last_item();
  65. (S).forall_loop_test((S).Forall_Loop_Item(),x);
  66. (S).loop_to_pred((S).Forall_Loop_Item()))
  67. #define forall_defined(x,S)
  68. for((S).Forall_Loop_Item()=(S).first_item();
  69. (S).forall_defined_test((S).Forall_Loop_Item(),x);
  70. (S).loop_to_succ((S).Forall_Loop_Item()))
  71. #endif
  72. #endif
  73. #endif