1 /* Copyright (c) 2012-2014, 2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 import java.util.ArrayList;
11 private ArrayList<Integer> nodes;
14 public Bucket(int id) {
15 this.nodes = new ArrayList<>();
27 public boolean contains(int id) {
28 return nodes.contains(id);
31 /* Add a node to the front of the bucket */
32 public void add(int id) {
36 /* Push a node to the front of a bucket */
37 public void pushToFront(int id) {
38 int i = nodes.indexOf(id);
43 public int getNode(int id) {
47 /* Add the content of the bucket into a answer object. */
48 public void addToAnswer(Answer answer, int destination) {
49 for (int nodeId : this.nodes) {
50 answer.getNodes().add(new Contact(nodeId,nodeId ^ destination));
55 public String toString() {
56 return "Bucket [id= " + id + " nodes=" + nodes + "]";