Made random generation of BigIntegers faster

2023-02-27 Thread Fabio Romano
This enhancement makes the generation of random BigIntegers faster, using directly a random generated int[] magnitude array instead of a byte[] array. This permits to call trustedStripLeadingZeroInts() instead of stripLeadingZeroBytes(), in order to avoid copying the contents of the byte[] array in

New class for handling infinite-precision rationals

2023-02-21 Thread Fabio Romano
The Rational class provides operations for arithmetic, rounding, comparison, hashing, and format conversion. The toString method provides a canonical representation of a Rational. All the calculations performed have an exact result, except for the square and nth roots, in which the user can specify

New subclass of BitSet "NaturalsBitSet" to store cardinality in a field

2023-01-22 Thread Fabio Romano
This enanchment is useful for applications that make heavy use of BitSet objects as sets of integers, and therefore they need to make a lot of calls to cardinality() method, which in BitSet class require linear time in the number of words in use by the bit set. This optimization reduces the cost of

[PATCH]: Code optimization for BitSet

2023-01-11 Thread Fabio Romano
The cardinality is saved as a field, new method for testing subset relation. The enanchment is useful for applications that make heavy use of BitSet objects as sets of integers, and therefore they need to make a lot of calls to cardinality() method, which actually require linear time in the number

[PATCH] 8173962: Add API for Deep copy of multi-dimensional arrays

2023-01-11 Thread Fabio Romano
Added the methods deepCopyOf(U[] original, Class newType) and deepCopyOf(T[] original), that perform a deep copy of the structure of multidimensional arrays. Also, added a pre-calculation of the string builders capacity for toString() of primitive array types, based on the mold of BitSet.toString()