org.bouncycastle.tsp.ers.ByteArrayComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polaris-all Show documentation
Show all versions of polaris-all Show documentation
All in one project for polaris-java
package org.bouncycastle.tsp.ers;
import java.util.Comparator;
/**
* Comparator for byte arrays for ERS hash sorting.
*/
class ByteArrayComparator
implements Comparator
{
public int compare(Object l, Object r)
{
byte[] left = (byte[])l;
byte[] right = (byte[])r;
for (int i = 0; i < left.length && i < right.length; i++)
{
int a = (left[i] & 0xff);
int b = (right[i] & 0xff);
if (a != b)
{
return a - b;
}
}
return left.length - right.length;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy