00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.group.topology;
00032
00033 import org.objectweb.proactive.core.group.Group;
00034 import org.objectweb.proactive.core.mop.ConstructionOfReifiedObjectFailedException;
00035
00036
00042 public class Ring extends TopologyGroup {
00043
00045 protected int width;
00046
00053 public Ring(Group g, int size)
00054 throws ConstructionOfReifiedObjectFailedException {
00055 super(g, size);
00056 this.width = size;
00057 }
00058
00063 public int getWidth() {
00064 return this.width;
00065 }
00066
00072 public int getX(Object o) {
00073 return this.indexOf(o);
00074 }
00075
00081 public Object left(Object o) {
00082 int position = this.indexOf(o);
00083 if (position != 0) {
00084 return this.get(position - 1);
00085 } else {
00086 return this.get(this.getWidth() - 1);
00087 }
00088 }
00089
00095 public Object right(Object o) {
00096 int position = this.indexOf(o);
00097 if (position != this.getWidth() - 1) {
00098 return this.get(position + 1);
00099 } else {
00100 return this.get(0);
00101 }
00102 }
00103 }