public void put(final long key, final int value) {
        putCount++;

        if (value < 0 || value > maxvalue) {
            throw new IllegalArgumentException("value out of range (0.." + maxvalue + "): " + value);
        }

        final int blockn = (int) (key >> blocksizeBits);
        final int offset = (int) (key & blocksizeBitsMask);

        byte[] block = blockn < blocklist.size() ? blocklist.get(blockn) : null;

        int valuebits = 1;
        if (block == null) {
            block = new byte[sizeForBits(valuebits)];
            bitplaneCount[0]++;

            while (blocklist.size() < blockn + 1) {
                blocklist.add(null);
            }
            blocklist.set(blockn, block);
        } else {
            // check how many bitplanes we have from the arraysize
            while (sizeForBits(valuebits) < block.length) {
                valuebits++;
            }
        }
        int headersize = 1 << valuebits;

        final byte v = (byte) (value + 1); // 0 is reserved (=unset)

        // find the index in the lookup table or the first entry
        int idx = 1;
        while (idx < headersize) {
            if (block[idx] == 0) {
                block[idx] = v; // create new entry
            }
            if (block[idx] == v) {
                break;
            }
            idx++;
        }
        if (idx == headersize) {
            block = expandBlock(block, valuebits);
            block[idx] = v; // create new entry
            blocklist.set(blockn, block);
            valuebits++;
            headersize = 1 << valuebits;
        }

        final int bitmask = 1 << (offset & 0x7);
        final int invmask = bitmask ^ 0xff;
        int probebit = 1;
        int blockidx = (offset >> 3) + headersize;

        for (int i = 0; i < valuebits; i++) {
            if ((idx & probebit) != 0) {
                block[blockidx] |= bitmask;
            } else {
                block[blockidx] &= invmask;
            }
            probebit <<= 1;
            blockidx += blocksize;
        }
    }
Creates a DenseLongMap for the given block size

@param blocksize bytes per bit-plane
main/src/main/java/cgeo/geocaching/brouter/util/DenseLongMap.java