public class BusConnectionsPriQ
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BusConnectionsPriQ.BusFunction |
| Constructor and Description |
|---|
BusConnectionsPriQ(int[] counts)
Priority queue of buses ordered by connection counts.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
dec(int bus)
Decrement the connection count for a bus
|
boolean |
forEach(BusConnectionsPriQ.BusFunction f)
Iterate through each bus in priority order until the end, or else told to stop.
|
int |
getCount(int bus) |
void |
inc(int bus)
Increment the connection count for a bus
|
int |
peek()
Return a bus with the lowest (but nonzero) number of connections
|
public BusConnectionsPriQ(int[] counts)
counts - array of connection counts for each bus.public int peek()
public boolean forEach(BusConnectionsPriQ.BusFunction f)
f - function to apply on each buspublic int getCount(int bus)
public void inc(int bus)
bus - bus to increment the number of connectionspublic boolean dec(int bus)
bus - bus to decrement the number of connections