Code example for ByteBuffer

Methods: get, getInt, hasRemaining, position

    private static final int  DEFAULT_SIZE     = 33;
    private static final long serialVersionUID = 1L;
    public static NodeIdSet readWireForm(ByteBuffer bytes, int idx, int len) {
        assert bytes.hasRemaining() : "Empty byte buffer";
        byte[] storage = new byte[bytes.getInt()];
        return new NodeIdSet(storage);
     * use a byte array to hold the bits for messaging efficency. 
    private byte[] storage;
     * create a bitset with a default size 
    public NodeIdSet() {