import java.util.List; import java.util.Map; public interface IChannelNode extends Comparable { enum Direction { INCOMING(1 << 0), // Users incoming from outside channel (aka: other channel forwarded this channel's post) OUTGOING(1 << 1), // Users outgoing from this channel (aka: this channel forwarded someone else's post) BOTH(INCOMING.val | OUTGOING.val); // Modify both incoming and outgoing counts at once private final int val; Direction(int val) {this.val = val;} public int getVal() {return this.val;} public interface callback { void cb(); } public static void overVals(Map cmap, Direction dir) throws IllegalArgumentException { if(cmap == null) throw new IllegalArgumentException("callback map is null"); if(dir == null) throw new IllegalArgumentException("dir is null"); for(Direction cdir: cmap.keySet()) if(cdir == null) throw new IllegalArgumentException("One of the directions is null"); for(callback cb: cmap.values()) if(cb == null) throw new IllegalArgumentException("One of the callbacks is null"); // For each direction in the map, check that the given direction is gte, and if so run the callback for(Direction cdir: cmap.keySet()) if((dir.getVal() & cdir.getVal()) > 0) cmap.get(cdir).cb(); } // This is hilariously overengineered because java fucking sucks my entire cock and balls // Barely even saves any space too } void setConnections(Map conmap, Direction dir); void setNumConnections(IChannelNode node, Direction dir, int num); void addConnection(IChannelNode node, Direction dir); void addConnections(Iterable nodes, Direction dir); void removeConnection(IChannelNode node, Direction dir); void removeConnections(Iterable nodes, Direction dir); void clearConnections(); boolean connectionExists(IChannelNode node, Direction dir); int getNumConnections(Direction dir); Map getIncomingConnections(); Map getOutgoingConnections(); List> getConnections(Direction dir); }