This commit is contained in:
wentch
2015-12-21 10:14:06 +08:00
parent c2116be358
commit db912ddf38
2 changed files with 4 additions and 76 deletions

View File

@@ -37,13 +37,13 @@ public abstract class Factory<R extends Reader, W extends Writer> {
private final Encodeable<W, ?> anyEncoder = new AnyEncoder(this);
//-----------------------------------------------------------------------------------
private final HashedMap<Class, Creator> creators = new HashedMap();
private final ConcurrentHashMap<Class, Creator> creators = new ConcurrentHashMap();
private final Map<String, Class> entitys = new ConcurrentHashMap();
private final ConcurrentHashMap<String, Class> entitys = new ConcurrentHashMap();
private final HashedMap<Type, Decodeable<R, ?>> decoders = new HashedMap();
private final ConcurrentHashMap<Type, Decodeable<R, ?>> decoders = new ConcurrentHashMap();
private final HashedMap<Type, Encodeable<W, ?>> encoders = new HashedMap();
private final ConcurrentHashMap<Type, Encodeable<W, ?>> encoders = new ConcurrentHashMap();
private final HashMap<AccessibleObject, ConvertColumnEntry> columnEntrys = new HashMap();

View File

@@ -1,72 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.convert;
import java.lang.reflect.*;
/**
* 只增不减的伪Map类
*
* @see http://www.redkale.org
* @author zhangjx
* @param <K>
* @param <V>
*/
@SuppressWarnings("unchecked")
public final class HashedMap<K extends Type, V> {
protected final transient Entry<K, V>[] table;
public HashedMap() {
this(128);
}
public HashedMap(int initCapacity) {
this.table = new Entry[Math.max(initCapacity, 16)];
}
public final V get(final K key) {
final K k = key;
final Entry<K, V>[] data = this.table;
Entry<K, V> entry = data[k.hashCode() & (data.length - 1)];
while (entry != null) {
if (k == entry.key) return entry.value;
entry = entry.next;
}
return null;
}
public final V put(K key, V value) {
final K k = key;
final Entry<K, V>[] data = this.table;
final int index = k.hashCode() & (data.length - 1);
Entry<K, V> entry = data[index];
while (entry != null) {
if (k == entry.key) {
V old = entry.value;
entry.value = value;
return old;
}
entry = entry.next;
}
data[index] = new Entry(key, value, data[index]);
return null;
}
protected static final class Entry<K, V> {
protected V value;
protected final K key;
protected final Entry<K, V> next;
protected Entry(K key, V value, Entry<K, V> next) {
this.key = key;
this.value = value;
this.next = next;
}
}
}