public TableColumnValueSortedEnumerator(Collection<IReadableTable.TableReader> readers, int colIndex, final Comparator<String> comparator) { this.readers = readers; this.colIndex = colIndex; this.comparator = comparator; pq = new PriorityQueue<ReaderBuffer>(11, new Comparator<ReaderBuffer>() { @Override public int compare(ReaderBuffer i, ReaderBuffer j) { boolean isEmpty1 = i.empty(); boolean isEmpty2 = j.empty(); if (isEmpty1 && isEmpty2) return 0; if (isEmpty1 && !isEmpty2) return 1; if (!isEmpty1 && isEmpty2) return -1; return comparator.compare(i.peek(), j.peek()); } }); for (IReadableTable.TableReader reader : readers) { if (reader != null) { try { pq.add(new ReaderBuffer(reader)); } catch (IOException e) { e.printStackTrace(); } } } }
public TableColumnValueSortedEnumerator(Collection<IReadableTable.TableReader> readers, int colIndex, final Comparator<String> comparator) { this.readers = readers; this.colIndex = colIndex; this.comparator = comparator; pq = new PriorityQueue<ReaderBuffer>(11, new Comparator<ReaderBuffer>() { @Override public int compare(ReaderBuffer i, ReaderBuffer j) { boolean isEmpty1 = i.empty(); boolean isEmpty2 = j.empty(); if (isEmpty1 && isEmpty2) return 0; if (isEmpty1 && !isEmpty2) return 1; if (!isEmpty1 && isEmpty2) return -1; return comparator.compare(i.peek(), j.peek()); } }); for (IReadableTable.TableReader reader : readers) { if (reader != null) { try { pq.add(new ReaderBuffer(reader)); } catch (IOException e) { e.printStackTrace(); } } } }