Skip to content

Commit

Permalink
Update kala.collection.internal.hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Jun 7, 2024
1 parent 7fda633 commit 0d28c4e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 114 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
/*
* Copyright 2024 Glavo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kala.collection.internal.hash;

import kala.function.Hasher;
import org.jetbrains.annotations.Nullable;

import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

import static kala.collection.internal.hash.HashUtils.tableSizeFor;

public abstract class HashBase<K, N extends HashNode<K, N>> implements Serializable {
@Serial
private static final long serialVersionUID = 5938151855937027660L;

protected static final int DEFAULT_INITIAL_CAPACITY = 16;
Expand Down Expand Up @@ -100,7 +117,7 @@ protected final N removeNode(K elem, int hash) {
return null;
}

if (nd.hash == hash && hasher.test(nd.key, elem)) {
if (nd.hash == hash && hasher.equals(nd.key, elem)) {
table[idx] = nd.next;
contentSize -= 1;
return nd;
Expand All @@ -111,7 +128,7 @@ protected final N removeNode(K elem, int hash) {
N next = nd.next;

while (next != null && next.hash <= hash) {
if (next.hash == hash && hasher.test(next.key, elem)) {
if (next.hash == hash && hasher.equals(next.key, elem)) {
prev.next = next.next;
contentSize -= 1;
return next;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Glavo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kala.collection.internal.hash;

import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Glavo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kala.collection.internal.hash;

public final class HashUtils {
Expand Down

0 comments on commit 0d28c4e

Please sign in to comment.