Advertisement
Guest User

Untitled

a guest
Jun 30th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. module Standard {
  3. module Algorithms {
  4. Filter(this, comp) {
  5. comptype := Expression(Utility.Forward(comp)).Type;
  6. thistype := Expression(Utility.Forward(this)).Type;
  7. if ((Utility.IsMovable(comptype) && comptype.IsRRef()) || Utility.IsCopyable(comptype)
  8. && (Utility.IsMovable(thistype) && thistype.IsRRef()) || Utility.IsCopyable(thistype)) {
  9. it_type := type {
  10. };
  11. resulttype := type {
  12. func := Utility.Forward(comp);
  13. src := Utility.Forward(this);
  14. };
  15. return resulttype();
  16. }
  17. // Not suitable for lazy evalutation, eagerly evaluate.
  18. result := Containers.Vector(Compiler.Expression(*this.Begin).Type)();
  19. while(this) {
  20. x := *this.Begin;
  21. if (comp(x)) result.Insert(result.Back(), x);
  22. ++this.Begin;
  23. }
  24. return result;
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement