publicclass VectorArrays { staticboolean equals(byte[] a, byte[] b) { if (a == b) returntrue; if (a == null || b == null) returnfalse;
int length = a.length; if (b.length != length) returnfalse;
return mismatch(a, b) < 0;
}
staticint compare(byte[] a, byte[] b) { if (a == b) return0; if (a == null || b == null) return a == null ? -1 : 1;
int i = mismatch(a, b); if (i >= 0) { returnByte.compare(a[i], b[i]);
}
return a.length - b.length;
}
staticint mismatch(byte[] a, byte[] b) {
VectorSpecies<Byte> species = ByteVector.SPECIES_256; return mismatch(a, b, species);
}
staticint mismatch(byte[] a, byte[] b, VectorSpecies<Byte> species) { int length = Math.min(a.length, b.length); if (a == b) return -1;
int i = 0; // @@@ Method on species to truncate the length? for (; i < (length & ~(species.length() - 1)); i += species.length()) {
Vector<Byte> va = ByteVector.fromArray(species, a, i);
Vector<Byte> vb = ByteVector.fromArray(species, b, i);
VectorMask<Byte> m = va.compare(VectorOperators.NE, vb); // @@@ count number of leading zeros with explicit method if (m.anyTrue()) { break; // mismatch found
}
}
// @@@ Can use a shape of half the bit size // or a mask for (; i < length; i++) { if (a[i] != b[i]) return i;
}
return (a.length != b.length) ? length : -1;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.