CVS update: JGroups/src/org/jgroups/util Util.java

"Bela Ban" <[email protected]>
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/08/12 15:57:22

  Modified:    src/org/jgroups/util Util.java
  Log:
  added pickNext()
  
  Revision  Changes    Path
  1.271     +20 -1     JGroups/src/org/jgroups/util/Util.java
  
  Index: Util.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/util/Util.java,v
  retrieving revision 1.270
  retrieving revision 1.271
  diff -u -r1.270 -r1.271
  --- Util.java	5 Aug 2010 06:57:29 -0000	1.270
  +++ Util.java	12 Aug 2010 15:57:22 -0000	1.271
  @@ -35,7 +35,7 @@
   /**
    * Collection of various utility routines that can not be assigned to other classes.
    * @author Bela Ban
  - * @version $Id: Util.java,v 1.270 2010/08/05 06:57:29 belaban Exp $
  + * @version $Id: Util.java,v 1.271 2010/08/12 15:57:22 belaban Exp $
    */
   public class Util {
   
  @@ -2105,6 +2105,25 @@
           return array[index];
       }
   
  +    /**
  +     * Returns the object next to element in list
  +     * @param list
  +     * @param obj
  +     * @param <T>
  +     * @return
  +     */
  +    public static <T> T pickNext(List<T> list, T obj) {
  +        if(list == null || obj == null)
  +            return null;
  +        Object[] array=list.toArray();
  +        for(int i=0; i < array.length; i++) {
  +            T tmp=(T)array[i];
  +            if(tmp != null && tmp.equals(obj))
  +                return (T)array[(i+1) % array.length];
  +        }
  +        return null;
  +    }
  +
   
       public static View createView(Address coord, long id, Address ... members) {
           Vector<Address> mbrs=new Vector<Address>();
  
  
  

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.