-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBitInputStream.java
More file actions
39 lines (33 loc) · 903 Bytes
/
BitInputStream.java
File metadata and controls
39 lines (33 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Copyright 2019-Present DataCompressionPrimitives.
*
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*/
package org.dcp.io;
import java.util.Iterator;
import org.dcp.entities.bit.Bit;
public interface BitInputStream {
public Bit readBit();
public default Iterable<Bit> readBits(final int toRead) {
return () -> {
return new Iterator<Bit>() {
int readIter = 0;
@Override
public boolean hasNext() {
return (readIter < toRead);
}
@Override
public Bit next() {
++readIter;
return readBit();
}
};
};
}
public default void skipBits(final int toRead) {
readBits(toRead).forEach(bit -> {});
}
}