-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
+/* Copyright (c) 2012-2019. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
nodes = new ArrayList<>();
}
- int getDestinationId() {
+ protected int getDestinationId() {
return destinationId;
}
- ArrayList<Contact> getNodes() {
+ protected ArrayList<Contact> getNodes() {
return nodes;
}
- int size() {
+ protected int size() {
return nodes.size();
}
- public void remove(int index) {
- nodes.remove(index);
+ public void trim() {
+ if (nodes.size() > Common.BUCKET_SIZE)
+ nodes.subList(nodes.size() - Common.BUCKET_SIZE, nodes.size()).clear();
}
public void add(Contact contact) {
}
Collections.sort(nodes);
//Trim the list
- while (answer.size() > Common.BUCKET_SIZE) {
- answer.remove(answer.size() - 1);
- }
+ answer.trim();
+
return nbAdded;
}
/* Returns if the destination has been found */
public boolean destinationFound() {
- if (nodes.size() < 1) {
+ if (nodes.isEmpty()) {
return false;
}
Contact tail = nodes.get(0);