Class FastByteOperations


  • public class FastByteOperations
    extends java.lang.Object
    Utility code to do optimized byte-array comparison. This is borrowed and slightly modified from Guava's UnsignedBytes class to be able to compare arrays that start at non-zero offsets.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compareUnsigned​(byte[] b1, byte[] b2)  
      static int compareUnsigned​(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
      Lexicographically compare two byte arrays.
      static int compareUnsigned​(byte[] b1, int s1, int l1, java.nio.ByteBuffer b2)  
      static int compareUnsigned​(byte[] b1, int s1, int l1, java.nio.ByteBuffer b2, int s2, int l2)  
      static int compareUnsigned​(java.nio.ByteBuffer b1, byte[] b2, int s2, int l2)  
      static int compareUnsigned​(java.nio.ByteBuffer b1, int s1, int l1, byte[] b2, int s2, int l2)  
      static int compareUnsigned​(java.nio.ByteBuffer b1, java.nio.ByteBuffer b2)  
      static void copy​(byte[] src, int srcPosition, byte[] trg, int trgPosition, int length)  
      static void copy​(byte[] src, int srcPosition, java.nio.ByteBuffer trg, int trgPosition, int length)  
      static void copy​(java.nio.ByteBuffer src, int srcPosition, byte[] trg, int trgPosition, int length)  
      static void copy​(java.nio.ByteBuffer src, int srcPosition, java.nio.ByteBuffer trg, int trgPosition, int length)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FastByteOperations

        public FastByteOperations()
    • Method Detail

      • compareUnsigned

        public static int compareUnsigned​(byte[] b1,
                                          int s1,
                                          int l1,
                                          byte[] b2,
                                          int s2,
                                          int l2)
        Lexicographically compare two byte arrays.
      • compareUnsigned

        public static int compareUnsigned​(java.nio.ByteBuffer b1,
                                          byte[] b2,
                                          int s2,
                                          int l2)
      • compareUnsigned

        public static int compareUnsigned​(byte[] b1,
                                          int s1,
                                          int l1,
                                          java.nio.ByteBuffer b2)
      • compareUnsigned

        public static int compareUnsigned​(java.nio.ByteBuffer b1,
                                          int s1,
                                          int l1,
                                          byte[] b2,
                                          int s2,
                                          int l2)
      • compareUnsigned

        public static int compareUnsigned​(byte[] b1,
                                          int s1,
                                          int l1,
                                          java.nio.ByteBuffer b2,
                                          int s2,
                                          int l2)
      • compareUnsigned

        public static int compareUnsigned​(java.nio.ByteBuffer b1,
                                          java.nio.ByteBuffer b2)
      • compareUnsigned

        public static int compareUnsigned​(byte[] b1,
                                          byte[] b2)
      • copy

        public static void copy​(byte[] src,
                                int srcPosition,
                                byte[] trg,
                                int trgPosition,
                                int length)
      • copy

        public static void copy​(java.nio.ByteBuffer src,
                                int srcPosition,
                                byte[] trg,
                                int trgPosition,
                                int length)
      • copy

        public static void copy​(byte[] src,
                                int srcPosition,
                                java.nio.ByteBuffer trg,
                                int trgPosition,
                                int length)
      • copy

        public static void copy​(java.nio.ByteBuffer src,
                                int srcPosition,
                                java.nio.ByteBuffer trg,
                                int trgPosition,
                                int length)