Skip to content

Commit 40cf37f

Browse files
committed
Minor refactored wrt #10, update release notes
1 parent 774830c commit 40cf37f

File tree

5 files changed

+62
-46
lines changed

5 files changed

+62
-46
lines changed

release-notes/CREDITS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ Here are individuals who have contributed to development of this project.
33

44
Tatu Saloranta, [email protected]: author
55

6-
6+
77

88
* Reported [Issue#6]: broken handling of '\r' (on Windows)
99
(0.7.2)
10+
11+
Nathan Williams (nathanlws@github)
12+
13+
* Contributed #10: Add Iterator-based(pull-style) sorter as an alternative
14+
(0.9.0)

release-notes/VERSION

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
Project: java-merge-sort
22
License: Apache License 2.0
3-
Version: 0.8.1
4-
Release date: 07-Aug-2013
3+
Version: 0.9.0
4+
Release date: xx-Oct-2013
55

6-
#8: Sorter._merge() not closing streams correctly
7-
(reported by tjoneslo@github)
6+
#10: Add Iterator-based (pull-style) sorter as an alternative
7+
(contributed by Nathan W)
88

99
------------------------------------------------------------------------
1010
=== History: ===
1111
------------------------------------------------------------------------
1212

13+
0.8.1 (07-Aug-2013)
14+
15+
#8: Sorter._merge() not closing streams correctly
16+
(reported by tjoneslo@github)
17+
1318
0.8.0 (24-Jul-2013)
1419

15-
* [Issue#6]: Incorrect handling of '\r'
20+
#6: Incorrect handling of '\r'
1621
(reported, patch contributed by [email protected])
1722

1823
0.7.1 (29-May-2012)
1924

20-
* [Issue#5]: Unnecessary object retention, leading to too high memory usage
25+
#5: Unnecessary object retention, leading to too high memory usage
2126
(reported by Paul Smith)
2227

2328

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fasterxml.sort;
2+
3+
import java.io.IOException;
4+
import java.util.Iterator;
5+
6+
/**
7+
* We need an unchecked exception to work with {@link Iterator}, and
8+
* want a specific subtype to catch.
9+
*/
10+
public class IterableSorterException extends RuntimeException {
11+
private static final long serialVersionUID = 1L;
12+
13+
public IterableSorterException(IOException cause) {
14+
super(cause);
15+
}
16+
}

src/main/java/com/fasterxml/sort/IteratingSorter.java

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.fasterxml.sort;
22

3+
import com.fasterxml.sort.util.CastingIterator;
34
import com.fasterxml.sort.util.SegmentedBuffer;
45

56
import java.io.Closeable;
@@ -137,50 +138,12 @@ public void close() {
137138
_merger = null;
138139
}
139140

140-
141-
/*
142-
/**********************************************************************
143-
/* Exception API
144-
/**********************************************************************
145-
*/
146-
147-
public static class IterableSorterException extends RuntimeException {
148-
public IterableSorterException(IOException cause) {
149-
super(cause);
150-
}
151-
}
152-
153-
154141
/*
155142
/**********************************************************************
156-
/* Iterator API
143+
/* Iterator implementations
157144
/**********************************************************************
158145
*/
159146

160-
private static class CastingIterator<T> implements Iterator<T> {
161-
private final Iterator<Object> _it;
162-
163-
public CastingIterator(Iterator<Object> it) {
164-
_it = it;
165-
}
166-
167-
@Override
168-
public boolean hasNext() {
169-
return _it.hasNext();
170-
}
171-
172-
@SuppressWarnings("unchecked")
173-
@Override
174-
public T next() {
175-
return (T)_it.next();
176-
}
177-
178-
@Override
179-
public void remove() {
180-
throw new UnsupportedOperationException();
181-
}
182-
}
183-
184147
private static class MergerIterator<T> implements Iterator<T> {
185148
private final DataReader<T> _merger;
186149
private T _next;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fasterxml.sort.util;
2+
3+
import java.util.Iterator;
4+
5+
public class CastingIterator<T> implements Iterator<T> {
6+
private final Iterator<Object> _it;
7+
8+
public CastingIterator(Iterator<Object> it) {
9+
_it = it;
10+
}
11+
12+
@Override
13+
public boolean hasNext() {
14+
return _it.hasNext();
15+
}
16+
17+
@SuppressWarnings("unchecked")
18+
@Override
19+
public T next() {
20+
return (T)_it.next();
21+
}
22+
23+
@Override
24+
public void remove() {
25+
throw new UnsupportedOperationException();
26+
}
27+
}

0 commit comments

Comments
 (0)