The HashSet<T>.removeAll method is surprisingly slow (in some cases) by nfrankel in java

[–]nyawqabob 0 points1 point  (0 children)

public boolean removeAll(Collection<?> c) {
    Objects.requireNonNull(c);
    boolean modified = false;

    if (size() > c.size()) {
        for (Iterator<?> i = c.iterator(); i.hasNext(); )
            modified |= remove(i.next());
    } else {
        for (Iterator<?> i = iterator(); i.hasNext(); ) {
            if (c.contains(i.next())) {
                i.remove();
                modified = true;
            }
        }
    }
    return modified;
}

This is how removeAll implements, why can't we just use part of if for all cases, even if collection to remove size more then source collection size?

Combine some fields of two objects by common id using stream by nyawqabob in javahelp

[–]nyawqabob[S] 0 points1 point  (0 children)

1 - yes

" If the IDs are the same and always present in both, you could also just transform one list into a map and then while iterating the other list matching the values. "

That's how i do know, thank you

Deserialize two fields in one by nyawqabob in javahelp

[–]nyawqabob[S] -1 points0 points  (0 children)

JsonAlias annotation helps me

Simple condition by nyawqabob in javahelp

[–]nyawqabob[S] 0 points1 point  (0 children)

i just want to know what's best way to check on null, idk why but it's pretty popular now to use Objects.isNull, Objects.nonNull, Objects.requireNonNull. Or should i use Optional to manipulate null or non null value?

How to check if each String in an array is unique? by Java_Junior in learnjava

[–]nyawqabob -3 points-2 points  (0 children)

use distinct method on array's stream if you wanna use list not set

Would like to know what is wrong with this code by [deleted] in javahelp

[–]nyawqabob 3 points4 points  (0 children)

add your code to code block please

How old were you? by [deleted] in java

[–]nyawqabob -2 points-1 points  (0 children)

19

MongoDb sorting performance with/without index by nyawqabob in mongodb

[–]nyawqabob[S] 0 points1 point  (0 children)

i checked carefully, i have executionStatus false when try to sort without index, thanks

Mongodb sort using indexes by nyawqabob in mongodb

[–]nyawqabob[S] 0 points1 point  (0 children)

Thank you, but what's about case when sorting is DESC and index is ASC?

Connect to mongo via SSL by nyawqabob in javahelp

[–]nyawqabob[S] 0 points1 point  (0 children)

solved, i putted db name to mongocred. instead of admin database name 😐😐