⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilidades.java

📁 java 实现的P2P Chord算法。chord算法是结构式的P2P搜索与管理协议
💻 JAVA
字号:
package org.mikel.jchord;/* * Utilidades.java * * Created on 23 de marzo de 2005, 12:34 */import java.math.*;import java.security.*;import java.text.*;import java.math.*;/** * * @author mikel */public class Utilidades {        BigInteger a;    Integer b;        public static BigInteger generarSHA1(String key){        try{            MessageDigest md = MessageDigest.getInstance("SHA-1");            byte[] hashMsg = md.digest(key.toString().getBytes());            return (new BigInteger(hashMsg)).abs();        } catch(Exception e){}        return null;    }        public static boolean entre(final BigInteger candidato, final BigInteger a, final BigInteger b, final boolean inclusivo) {        if (b.compareTo(a) >0 ){ // b>a            return(candidato.compareTo(a)>0 && (candidato.compareTo(b)<0 || candidato.compareTo(b)<=0 && inclusivo));        } else { //b<=a            return candidato.compareTo(a)>0 || (candidato.compareTo(b)<0 || candidato.compareTo(b)<=0 && inclusivo);        }    }        public static boolean between(final BigInteger _candidate, final BigInteger _b1, final BigInteger _b2, final boolean _inclusive) {        if (_inclusive && (_candidate.equals(_b1) || _candidate.equals(_b2)))            return true;                return _candidate.compareTo(_b2) == -1 && _candidate.compareTo(_b1) == 1;    }                public static boolean bigIntegerMayorQue(BigInteger s1, BigInteger s2){        return s1.compareTo(s2) > 0;    }    public static boolean bigIntegerMenorQue(BigInteger s1, BigInteger s2){        return s1.compareTo(s2) < 0;    }    public static boolean bigIntegerIgualQue(BigInteger s1, BigInteger s2){        return s1.compareTo(s2) == 0;    }        public static boolean bigIntegerNoIgualQue(BigInteger s1, BigInteger s2){        return s1.compareTo(s2) != 0;    }    public static boolean bigIntegerMayorOIgualQue(BigInteger s1, BigInteger s2){        return s1.compareTo(s2) >= 0;    }    public static boolean bigIntegerMenorOIgualQue(BigInteger s1, BigInteger s2){                return s1.compareTo(s2) <= 0;    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -