private long pathIdCounter = 0L;
private int addRoute(final RouteKey key, final ContainerNode attributes) {
- this.pathIdCounter++;
int offset = this.offsets.offsetOf(key);
if (offset < 0) {
final OffsetMap<RouteKey> newOffsets = this.offsets.with(key);
this.values = newAttributes;
this.offsets = newOffsets;
this.pathsId = newPathsId;
+ this.offsets.setValue(this.pathsId, offset, this.pathIdCounter++);
}
-
this.offsets.setValue(this.values, offset, attributes);
- this.offsets.setValue(this.pathsId, offset, this.pathIdCounter);
LOG.trace("Added route from {} attributes {}", key.getRouteId(), attributes);
return offset;
}
this.values = this.offsets.removeValue(this.values, offset);
this.pathsId = this.offsets.removeValue(this.pathsId, offset);
this.offsets = this.offsets.without(key);
- return this.offsets.size() == 0;
+ return isEmpty();
}
@Override
return this.offsets;
}
+ public final boolean isEmpty() {
+ return this.offsets.isEmty();
+ }
+
protected void selectBest(final RouteKey key, final AddPathSelector selector) {
final int offset = this.offsets.offsetOf(key);
final ContainerNode attributes = this.offsets.getValue(this.values, offset);
final List<AddPathBestPath> newBestPathList = new ArrayList<>();
final List<RouteKey> keyList = this.offsets.getRouteKeysList();
- if(!keyList.isEmpty()) {
+ if (!keyList.isEmpty()) {
/* we set the best path first on List for not supported Add path cases*/
final AddPathBestPath newBest = selectBest(localAs, keyList);
newBestPathList.add(newBest);
}
this.bestPathRemoved = new ArrayList<>(this.bestPath);
- if (this.bestPathRemoved.removeAll(newBestPathList) || !this.bestPath.equals(newBestPathList)) {
+ if (this.bestPathRemoved.removeAll(newBestPathList) && !this.bestPathRemoved.isEmpty() || !this.bestPath.equals(newBestPathList)) {
this.bestPath = newBestPathList;
LOG.trace("Actual Best {}, removed best {}", this.bestPath, this.bestPathRemoved);
return true;
}
this.bestPathRemoved = new ArrayList<>(this.bestPath);
- if (this.bestPathRemoved.removeAll(newBestPathList) || !this.bestPath.equals(newBestPathList)) {
+ if (this.bestPathRemoved.removeAll(newBestPathList) && !this.bestPathRemoved.isEmpty() || !this.bestPath.equals(newBestPathList)) {
this.bestPath = newBestPathList;
LOG.trace("Actual Best {}, removed best {}", this.bestPath, this.bestPathRemoved);
return true;