javolution.util.internal.map.FractalMapImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javolution-core-java-msftbx
Show all versions of javolution-core-java-msftbx
Only the Java Core part of Javolution library, with slight modifications for use in MSFTBX.
The newest version!
/*
* Javolution - Java(TM) Solution for Real-Time and Embedded Systems
* Copyright (C) 2012 - Javolution (http://javolution.org/)
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software is
* freely granted, provided that this notice is preserved.
*/
package javolution.util.internal.map;
import javolution.util.function.Equality;
/**
* A fractal-based map with rehash performed only on limited size maps.
* It is based on a fractal structure with self-similar patterns at any scale
* (maps holding submaps). At each depth only a part of the hashcode is used
* starting by the last bits.
*/
@SuppressWarnings("rawtypes")
final class FractalMapImpl {
static final int EMPTINESS_LEVEL = 2; // Can be 1 (load factor 0.5), 2 (load factor 0.25) or any greater value.
static final int INITIAL_BLOCK_CAPACITY = 2 << EMPTINESS_LEVEL;
static final int SHIFT = 10; // Number of hashcode bits per depth.
//private static final int MAX_BLOCK_CAPACITY = 1 << SHIFT;
private int count; // Number of entries different from null in this block.
private MapEntryImpl[] entries = new MapEntryImpl[INITIAL_BLOCK_CAPACITY]; // Entries value can be a sub-map.
private final int shift; // Zero if base map.
final Equality