public byte[][] generateKeys(final int nkeys){
  if (nkeys < 0)   throw new IllegalArgumentException();
  if (nkeys > maxKeys)   throw new IllegalArgumentException();
  final Set<byte[]> set=new TreeSet<byte[]>(BytesUtil.UnsignedByteArrayComparator.INSTANCE);
  final byte[][] keys=new byte[maxKeys][];
  int n=0;
  while (n < maxKeys) {
    final byte[] key=new byte[r.nextInt(maxKeyLength) + 1];
    r.nextBytes(key);
    if (set.add(key)) {
      keys[n++]=key;
    }
  }
  Arrays.sort(keys,BytesUtil.UnsignedByteArrayComparator.INSTANCE);
  for (int i=nkeys; i < maxKeys; i++) {
    keys[i]=null;
  }
  return keys;
}

public byte [ ] [ ] generateKeys ( final int nkeys ) { if ( nkeys < 0 ) throw new IllegalArgumentException ( ) ; if ( nkeys > maxKeys ) throw new IllegalArgumentException ( ) ; final Set < byte [ ] > set = new TreeSet < byte [ ] > ( BytesUtil . UnsignedByteArrayComparator . INSTANCE ) ; final byte [ ] [ ] keys = new byte [ maxKeys ] [ ] ; int n = 0 ; while ( n < maxKeys ) { final byte [ ] key = new byte [ r . nextInt ( maxKeyLength ) + 1 ] ; r . nextBytes ( key ) ; if ( set . add ( key ) ) { keys [ n ++ ] = key ; } } Arrays . sort ( keys , BytesUtil . UnsignedByteArrayComparator . INSTANCE ) ; for ( int i = nkeys ; i < maxKeys ; i ++ ) { keys [ i ] = null ; } return keys ; }
generate a set of n random distinct byte [ ] keys in sorted order using an unsigned byte [ ] comparison function .
