/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ package ds.util; abstract public class Function2 { // apply a binary function abstract public Z apply(X x, Y y); public Function2 flip() { return new Flip(this); } private static class Flip extends Function2 { private final Function2 f; public Flip(Function2 f) { this.f = f; } public Z apply(X x, Y y) { return f.apply(y, x); } } }