All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.bezsias.multimap.CompactByteArrayMultiMap Maven / Gradle / Ivy

package com.github.bezsias.multimap;

import java.util.*;
import java.io.*;

public class CompactByteArrayMultiMap extends CompactMultiMap {

    CompactByteArrayMultiMap(BytePackager packager, MapFactory mapFactory) throws IOException {
        super(packager, mapFactory);
    }

    protected int getIndex(List values, byte[] value) {
        for (int i = 0, n = values.size(); i < n ; i++) {
            if (Arrays.equals(values.get(i), value)) return i;
        }
        return -1;
    }

    @Override
    protected boolean remove(List values, byte[] value) {
        int idx = getIndex(values, value);
        if (idx == -1) return false;
        else {
            values.remove(idx);
            return true;
        }
    }

    @Override
    protected boolean contains(List values, byte[] value) {
        return getIndex(values, value) != -1;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy