1 31 34 package org.objectweb.proactive.core.group.topology; 35 36 import org.objectweb.proactive.core.group.Group; 37 import org.objectweb.proactive.core.mop.ConstructionOfReifiedObjectFailedException; 38 39 40 45 public class Ring extends TopologyGroup { 47 48 protected int width; 49 50 56 public Ring(Group g, int size) 57 throws ConstructionOfReifiedObjectFailedException { 58 super(g, size); 59 this.width = size; 60 } 61 62 66 public int getWidth() { 67 return this.width; 68 } 69 70 75 public int getX(Object o) { 76 return this.indexOf(o); 77 } 78 79 84 public Object left(Object o) { 85 int position = this.indexOf(o); 86 if (position != 0) { 87 return this.get(position - 1); 88 } else { 89 return this.get(this.getWidth()); 90 } 91 } 92 93 98 public Object right(Object o) { 99 int position = this.indexOf(o); 100 if (position != this.getWidth()) { 101 return this.get(position + 1); 102 } else { 103 return this.get(0); 104 } 105 } 106 } 107 | Popular Tags |