类 Misc


  • public class Misc
    extends Object
    Miscellaneous static routines.
    作者:
    caron
    • 构造器详细资料

      • Misc

        public Misc()
    • 方法详细资料

      • howClose

        public static double howClose​(double d1,
                                      double d2)
      • closeEnough

        public static boolean closeEnough​(double v1,
                                          double v2,
                                          double maxRelDiff)
        Check if numbers are equal with given reletive tolerance
        参数:
        v1 - first floating point number
        v2 - second floating point number
        maxRelDiff - maximum reletive difference
        返回:
        true if within tolerance
      • closeEnough

        public static boolean closeEnough​(double v1,
                                          double v2)
        Check if numbers are equal with default tolerance
        参数:
        v1 - first floating point number
        v2 - second floating point number
        返回:
        true if within tolerance
      • closeEnough

        public static boolean closeEnough​(float v1,
                                          float v2,
                                          float maxRelDiff)
      • closeEnough

        public static boolean closeEnough​(float v1,
                                          float v2)
        Check if numbers are equal with default tolerance
        参数:
        v1 - first floating point number
        v2 - second floating point number
        返回:
        true if within tolerance
      • closeEnoughAbs

        public static boolean closeEnoughAbs​(double v1,
                                             double v2,
                                             double maxAbsDiff)
        Check if numbers are equal with given absolute tolerance
        参数:
        v1 - first floating point number
        v2 - second floating point number
        maxAbsDiff - maximum absolute difference
        返回:
        true if within tolerance
      • closeEnoughAbs

        public static boolean closeEnoughAbs​(float v1,
                                             float v2,
                                             float maxAbsDiff)
      • showInts

        public static String showInts​(int[] inta)
      • showInts

        public static void showInts​(int[] inta,
                                    Formatter f)
      • showBytes

        public static String showBytes​(byte[] buff)
      • showBytes

        public static void showBytes​(byte[] buff,
                                     Formatter f)
      • getSize

        public static int getSize​(Iterable ii)
      • getTestdataDirPath

        public static String getTestdataDirPath()
      • compare

        public static boolean compare​(byte[] raw1,
                                      byte[] raw2,
                                      Formatter f)
      • compare

        public static void compare​(float[] raw1,
                                   float[] raw2,
                                   Formatter f)
      • compare

        public static int compare​(int x,
                                  int y)
      • compare

        public static int compare​(long x,
                                  long y)
      • getProtocols

        public static List<String> getProtocols​(String url)
        Return the set of leading protocols for a url; may be more than one. Watch out for Windows paths starting with a drive letter => protocol names must all have a length > 1. Watch out for '::' Each captured protocol is saved without trailing ':' Assume: the protocols MUST be terminated by the occurrence of '/'.
        参数:
        url - the url whose protocols to return
        返回:
        list of leading protocols without the trailing :
      • validateprotocol

        protected static boolean validateprotocol​(String url,
                                                  int startpos,
                                                  int endpos)
      • main

        public static void main​(String[] args)
        test