X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Futil%2FIntegerTopology.java;h=73de98879d5527349950278b1ca76431cc454c19;hb=23091054a6842031d168c2628216c2310149cc5d;hp=ae99c083880cb7d2bda7ec5fa616422139fa66ba;hpb=61a641445b4f0916427804a6168b87fcde977abf;p=sbp.git diff --git a/src/edu/berkeley/sbp/util/IntegerTopology.java b/src/edu/berkeley/sbp/util/IntegerTopology.java index ae99c08..73de988 100644 --- a/src/edu/berkeley/sbp/util/IntegerTopology.java +++ b/src/edu/berkeley/sbp/util/IntegerTopology.java @@ -15,6 +15,7 @@ public class IntegerTopology implements Topology { private int toInt(V v) { return f==null?((IntegerMappable)v).toInt():f.invoke(v); } public Range.Set getRanges() { return new Range.Set(rs); } + public Functor functor() { return f; } public IntegerTopology(Functor f) { this(f, new Range.Set()); } public IntegerTopology(Functor f, V a) { this(f, f==null?((IntegerMappable)a).toInt():f.invoke(a)); } @@ -23,8 +24,11 @@ public class IntegerTopology implements Topology { public IntegerTopology(Functor f, int a) { this(f, a, a); } public IntegerTopology(Functor f, int a, int b) { this(f, new Range(a, b)); } public IntegerTopology(Functor f, Range r) { this(f, new Range.Set(r)); } - public IntegerTopology(Functor f, Range.Set rs) { this.rs = rs; this.f = f; } - + public IntegerTopology(Functor f, Range.Set rs) { + this.rs = rs; + this.f = f==null?(this instanceof Functor ? (Functor)this : null):f; + } + public Topology empty() { return new IntegerTopology(f); } public boolean contains(V v) { return rs.contains(toInt(v)); }