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

net.jkcode.jkmvc.bit.IBitSet Maven / Gradle / Ivy

package net.jkcode.jkmvc.bit;

import net.jkcode.jkmvc.elements.IElements;

import java.util.AbstractSet;
import java.util.BitSet;
import java.util.Iterator;

/**
 * BitSet相关集合
 *   直接根据 BitSet 来修改 Set 的语义
 *   可用于实现 FixedKeyMap 的 EntrySet
 *
 * @author shijianhang
 * @date 2019-06-27 12:00 PM
 */
public abstract class IBitSet extends AbstractSet implements IElements {

    protected BitSet bits;

    public IBitSet(BitSet bits) {
        this.bits = bits;
    }

    /**
     * 获得BitSet中设置为 true 的位数
     * @return
     */
    @Override
    public int size() {
        return bits.cardinality();
    }

    /**
     * 获得迭代器
     * @return
     */
    @Override
    public Iterator iterator() {
        return new SetBitElementIterator(bits,this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy