mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-19 23:26:50 +00:00
perf[set]: use Boolean instead Object constant
This commit is contained in:
@@ -34,8 +34,6 @@ public abstract class ArrayUtils {
|
||||
public static final double[] EMPTY_DOUBLE_ARRAY = new double[0];
|
||||
public static final char[] EMPTY_CHAR_ARRAY = new char[0];
|
||||
|
||||
public static final Object EMPTY_OBJECT = new Object();
|
||||
|
||||
/**
|
||||
* unbox
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class HashSetByte extends AbstractSet<Byte> {
|
||||
|
||||
private final ByteObjectHashMap<Object> map;
|
||||
private final ByteObjectHashMap<Boolean> map;
|
||||
|
||||
public HashSetByte() {
|
||||
map = new ByteObjectHashMap<>();
|
||||
@@ -56,16 +56,16 @@ public class HashSetByte extends AbstractSet<Byte> {
|
||||
|
||||
@Override
|
||||
public boolean add(Byte e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
public boolean add(byte e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == ArrayUtils.EMPTY_OBJECT;
|
||||
return map.remove(o) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class HashSetInt extends AbstractSet<Integer> {
|
||||
|
||||
private final IntObjectHashMap<Object> map;
|
||||
private final IntObjectHashMap<Boolean> map;
|
||||
|
||||
public HashSetInt() {
|
||||
map = new IntObjectHashMap<>();
|
||||
@@ -56,16 +56,16 @@ public class HashSetInt extends AbstractSet<Integer> {
|
||||
|
||||
@Override
|
||||
public boolean add(Integer e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
public boolean add(int e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == ArrayUtils.EMPTY_OBJECT;
|
||||
return map.remove(o) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,16 +56,16 @@ public class HashSetLong extends AbstractSet<Long> {
|
||||
|
||||
@Override
|
||||
public boolean add(Long e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
public boolean add(long e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == ArrayUtils.EMPTY_OBJECT;
|
||||
return map.remove(o) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class HashSetShort extends AbstractSet<Short> {
|
||||
|
||||
private final ShortObjectHashMap<Object> map;
|
||||
private final ShortObjectHashMap<Boolean> map;
|
||||
|
||||
public HashSetShort() {
|
||||
map = new ShortObjectHashMap<>();
|
||||
@@ -56,16 +56,16 @@ public class HashSetShort extends AbstractSet<Short> {
|
||||
|
||||
@Override
|
||||
public boolean add(Short e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
public boolean add(short e) {
|
||||
return map.put(e, ArrayUtils.EMPTY_OBJECT) == null;
|
||||
return map.put(e, Boolean.TRUE) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == ArrayUtils.EMPTY_OBJECT;
|
||||
return map.remove(o) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user