vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.8k stars 197 forks source link

Add a fast toArray to ArraySet. #188

Closed techsy730 closed 3 years ago

techsy730 commented 3 years ago

Add a fast toArray to ArraySet

Also slightly expand the unit tests for object based toArrays

vigna commented 3 years ago

Hey, toArray() with a primitive-type array argument is deprecated upstream. I really think you have warnings disabled for deprecated methods, or you should see this. My suggestion is that of not implementing it at all (the docs say it will be removed in a future release).

techsy730 commented 3 years ago

Oops, I thought I overrode the right primitive toArray. I guess not.

And yep, "Signal overriding or implementing deprecated method" was unchecked for me. Oops

vigna commented 3 years ago

Yeah, probably we will get rid of it in 9.0.0. One day.

techsy730 commented 3 years ago

Actually, it is methods like toIntArray(int[]) that are deprecated. It says toArray(int[]) is the preferred one.

In Collection.drv

    /** Returns a primitive type array containing the items of this collection.
     * [...]
     * @deprecated Please use {@code toArray()} instead—this method is redundant and will be removed in the future.
     */
    @Deprecated
    default KEY_TYPE[] TO_KEY_ARRAY(KEY_TYPE a[]) {
        return toArray(a);
    }

    /** Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
     * [...]
     */
    KEY_TYPE[] toArray(KEY_TYPE a[]);
vigna commented 3 years ago

Oops, I remembered incorrectly. Well, at least now you have the warning on :).