Package xbird.util.collections.longs

Examples of xbird.util.collections.longs.Long2LongOpenHash$MapIterator


            return "{}";
        }
        StringBuffer buf = new StringBuffer(32 * size());
        buf.append('{');

        MapIterator it = mapIterator();
        boolean hasNext = it.hasNext();
        while (hasNext) {
            Object key = it.next();
            Object value = it.getValue();
            buf.append(key == this ? "(this Map)" : key).append('=').append(value == this ? "(this Map)" : value);

            hasNext = it.hasNext();
            if (hasNext) {
                buf.append(',').append(' ');
            }
        }

View Full Code Here


     * @param key1 the first key
     * @return true if any elements were removed
     */
    public boolean removeAll(Object key1) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 1 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
    }
View Full Code Here

     * @param key2 the second key
     * @return true if any elements were removed
     */
    public boolean removeAll(Object key1, Object key2) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 2 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
    }
View Full Code Here

     * @param key3 the third key
     * @return true if any elements were removed
     */
    public boolean removeAll(Object key1, Object key2, Object key3) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 3 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) && (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
    }
View Full Code Here

     * @param key4 the fourth key
     * @return true if any elements were removed
     */
    public boolean removeAll(Object key1, Object key2, Object key3, Object key4) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 4 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) && (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) && (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
    }
View Full Code Here

                }
                final FastBufferedInputStream bis = new FastBufferedInputStream(fis, 4096);
                this.recordMap = ObjectUtils.readObjectQuietly(bis);
                IOUtils.closeQuietly(bis);
            } else {
                this.recordMap = new Long2LongOpenHash(cacheSize, 0.7f, 1.9f);
            }
            this.descFile = file;
        }
View Full Code Here

    }

    public void put(int times) {
        StopWatch sw = new StopWatch("[Long2LongOpenHashTest] testPut" + times);
        List<Long> keys = new ArrayList<Long>(times);
        Long2LongOpenHash hash = new Long2LongOpenHash(times);
        Random random = new Random(System.currentTimeMillis());
        for(int i = 0; i < times; i++) {
            long key = random.nextLong();
            keys.add(key);
            long value = random.nextLong();
            hash.put(key, value);
            assertEquals(value, hash.get(key));
        }
        Long2LongOpenHash copyed = ObjectUtils.deepCopy(hash);
        assertEquals(hash.size(), copyed.size());
        for(int i = 0; i < times; i++) {
            long key = keys.get(i).longValue();
            assertEquals("Round#" + i, hash.get(key), copyed.get(key));
        }
        System.err.println(sw);
    }
View Full Code Here

TOP

Related Classes of xbird.util.collections.longs.Long2LongOpenHash$MapIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.