Skip to content

Commit 12d74ce

Browse files
misc
1 parent 0042ad4 commit 12d74ce

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

src/Tests/Test_KTopCollector.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public void loading() throws Exception {
5151
collectorA.store(new CtosInteger(stream));
5252

5353
final IEstimationCollector<Integer> collectorB = (new StoredKTop<Integer>( //
54+
3 //
55+
)).load( //
5456
new CtisInteger( //
5557
new ByteArrayInputStream(stream.toByteArray()) //
56-
), //
57-
3 //
58-
)).load();
58+
) //
59+
);
5960

6061
Assert.assertEquals( //
6162
collectorA.collect().toString(), //

src/Tests/Test_csTable.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public void loadIntTable() throws IOException {
2525
tableA.store(new DataOutputStream(stream));
2626

2727
CcsTable tableB = (new CcsStoredTable( //
28+
2, 1 //
29+
)).asInt( //
2830
new DataInputStream( //
2931
new ByteArrayInputStream(stream.toByteArray()) //
30-
), //
31-
2, 1 //
32-
)).asInt();
32+
) //
33+
);
3334

3435
Assert.assertEquals(tableA.read(0, 0), tableB.read(0, 0));
3536
Assert.assertEquals(tableA.read(1, 0), tableB.read(1, 0));

src/YASL/Collectors/StoredKTop.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,24 @@
77
import java.util.Map;
88

99
import YASL.CEstimationFor;
10-
import YASL.IEstimationCollector;
1110
import YASL.Streams.TypedInputStream;
1211

1312
public class StoredKTop<T> {
14-
private final TypedInputStream<T> _stream;
15-
private final int _size;
13+
private final int _size;
1614

17-
public StoredKTop(TypedInputStream<T> _stream, int _size) {
18-
this._stream = _stream;
15+
public StoredKTop(int _size) {
1916
this._size = _size;
2017
}
2118

22-
public IEstimationCollector<T> load() throws IOException {
23-
final int cnt = _stream.readInt();
19+
public KTopCollector<T> load(TypedInputStream<T> stream) throws IOException {
20+
final int cnt = stream.readInt();
2421
final List<CEstimationFor<T>> items = new ArrayList<>(cnt);
2522
final Map<T, CEstimationFor<T>> byValue = new HashMap<>();
2623

2724
for (int i = 0; i < cnt; i++) {
28-
final T item = _stream.readType();
29-
final long itemCount = _stream.readLong();
30-
final CEstimationFor<T> est= new CEstimationFor<>(item, itemCount);
25+
final T item = stream.readType();
26+
final long itemCount = stream.readLong();
27+
final CEstimationFor<T> est = new CEstimationFor<>(item, itemCount);
3128

3229
items.add(est);
3330
byValue.put(item, est);

src/YASL/Counters/Tables/CcsStoredTable.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
import java.io.IOException;
55

66
public class CcsStoredTable {
7-
private final DataInput _stream;
87
private final int _width;
98
private final int _depth;
109

11-
public CcsStoredTable(DataInput _stream, int _width, int _depth) {
12-
this._stream = _stream;
10+
public CcsStoredTable(int _width, int _depth) {
1311
this._width = _width;
1412
this._depth = _depth;
1513
}
1614

17-
public CcsIntTable asInt() throws IOException {
15+
public CcsIntTable asInt(DataInput stream) throws IOException {
1816
final int[][] data = new int[_depth][_width];
1917
for (int depth = 0; depth < _depth; depth++) {
2018
for (int cell = 0; cell < _width; cell++) {
21-
data[depth][cell] = _stream.readInt();
19+
data[depth][cell] = stream.readInt();
2220
}
2321
}
2422

0 commit comments

Comments
 (0)