public void init()
{
}
public HashObjectMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
}
public HashObjectMap() {
this.loadFactor = DEFAULT_LOAD_FACTOR;
threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
table = new BaseHashObject[DEFAULT_INITIAL_CAPACITY];
init();
}
public HashObjectMap(Set<BaseHashObject> m) {
this(Math.max((int) (m == null ? 16:m.size() / DEFAULT_LOAD_FACTOR) + 1,
DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR);
putAllForCreate(m);
}
private void putAllForCreate(Set<BaseHashObject> m)
{
if (m != null)
{
for (Iterator<BaseHashObject> i = m.iterator(); i.hasNext();)
{
BaseHashObject e = i.next();
putForCreate(e);
}
}
}
private void putForCreate(BaseHashObject object) {
if(object == null)
return;
int hash = object.keyHashCode();
int i = indexFor(hash, table.length);
/**
* Look for preexisting entry for key. This will never happen for
* clone or deserialize. It will only happen for construction if the
* input Map is a sorted map whose ordering is inconsistent w/ equals.
*/
for (HashObject e = table[i]; e != null; e = e.getNext()) {
if (e.keyHashCode() == hash && e.keyEquals(object)) {
e.copyObject(object);
return;
}
}
createObject(hash, object, i);
}
private void createObject(int hash, BaseHashObject object, int bucketIndex) {
BaseHashObject e = table[bucketIndex];
object.setNext(e);
table[bucketIndex] = object;
size++;
}
{
}
public HashObjectMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
}
public HashObjectMap() {
this.loadFactor = DEFAULT_LOAD_FACTOR;
threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
table = new BaseHashObject[DEFAULT_INITIAL_CAPACITY];
init();
}
public HashObjectMap(Set<BaseHashObject> m) {
this(Math.max((int) (m == null ? 16:m.size() / DEFAULT_LOAD_FACTOR) + 1,
DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR);
putAllForCreate(m);
}
private void putAllForCreate(Set<BaseHashObject> m)
{
if (m != null)
{
for (Iterator<BaseHashObject> i = m.iterator(); i.hasNext();)
{
BaseHashObject e = i.next();
putForCreate(e);
}
}
}
private void putForCreate(BaseHashObject object) {
if(object == null)
return;
int hash = object.keyHashCode();
int i = indexFor(hash, table.length);
/**
* Look for preexisting entry for key. This will never happen for
* clone or deserialize. It will only happen for construction if the
* input Map is a sorted map whose ordering is inconsistent w/ equals.
*/
for (HashObject e = table[i]; e != null; e = e.getNext()) {
if (e.keyHashCode() == hash && e.keyEquals(object)) {
e.copyObject(object);
return;
}
}
createObject(hash, object, i);
}
private void createObject(int hash, BaseHashObject object, int bucketIndex) {
BaseHashObject e = table[bucketIndex];
object.setNext(e);
table[bucketIndex] = object;
size++;
}