Skip to content

Commit

Permalink
method to get the rank of a member with respect to a view
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Sep 17, 2010
1 parent e938cb5 commit 3440dd6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/org/jgroups/util/Util.java
Expand Up @@ -37,7 +37,7 @@
/**
* Collection of various utility routines that can not be assigned to other classes.
* @author Bela Ban
* @version $Id: Util.java,v 1.273 2010/09/17 11:50:07 belaban Exp $
* @version $Id: Util.java,v 1.274 2010/09/17 13:03:55 belaban Exp $
*/
public class Util {

Expand Down Expand Up @@ -2115,6 +2115,18 @@ public static Collection<Address> determineMergeCoords(Map<Address,View> map) {
}


public static int getRank(View view, Address addr) {
if(view == null || addr == null)
return 0;
List<Address> members=view.getMembers();
for(int i=0; i < members.size(); i++) {
Address mbr=members.get(i);
if(mbr.equals(addr))
return i+1;
}
return 0;
}


public static Object pickRandomElement(List list) {
if(list == null) return null;
Expand Down

0 comments on commit 3440dd6

Please sign in to comment.