public Pair<T, T> mapRange(String col, T beginValue, T endValue, String returnCol) { int colIdx = tableDesc.findColumnByName(col).getZeroBasedIndex(); int returnIdx = tableDesc.findColumnByName(returnCol).getZeroBasedIndex(); Comparator<T> colComp = getComparator(colIdx); Comparator<T> returnComp = getComparator(returnIdx); T returnBegin = null; T returnEnd = null; for (T[] row : data.values()) { if (between(beginValue, row[colIdx], endValue, colComp)) { T returnValue = row[returnIdx]; if (returnBegin == null || returnComp.compare(returnValue, returnBegin) < 0) { returnBegin = returnValue; } if (returnEnd == null || returnComp.compare(returnValue, returnEnd) > 0) { returnEnd = returnValue; } } } if (returnBegin == null && returnEnd == null) return null; else return Pair.newPair(returnBegin, returnEnd); }
public Pair<T, T> mapRange(String col, T beginValue, T endValue, String returnCol) { int colIdx = tableDesc.findColumnByName(col).getZeroBasedIndex(); int returnIdx = tableDesc.findColumnByName(returnCol).getZeroBasedIndex(); T returnBegin = null; T returnEnd = null; for (T[] row : data.values()) { if (between(beginValue, row[colIdx], endValue)) { T returnValue = row[returnIdx]; if (returnBegin == null || returnValue.compareTo(returnBegin) < 0) { returnBegin = returnValue; } if (returnEnd == null || returnValue.compareTo(returnEnd) > 0) { returnEnd = returnValue; } } } if (returnBegin == null && returnEnd == null) return null; else return new Pair<T, T>(returnBegin, returnEnd); }
public Pair<T, T> mapRange(String col, T beginValue, T endValue, String returnCol) { int colIdx = tableDesc.findColumnByName(col).getZeroBasedIndex(); int returnIdx = tableDesc.findColumnByName(returnCol).getZeroBasedIndex(); T returnBegin = null; T returnEnd = null; for (T[] row : data.values()) { if (between(beginValue, row[colIdx], endValue)) { T returnValue = row[returnIdx]; if (returnBegin == null || returnValue.compareTo(returnBegin) < 0) { returnBegin = returnValue; } if (returnEnd == null || returnValue.compareTo(returnEnd) > 0) { returnEnd = returnValue; } } } if (returnBegin == null && returnEnd == null) return null; else return new Pair<T, T>(returnBegin, returnEnd); }
public Pair<T, T> mapRange(String col, T beginValue, T endValue, String returnCol) { int colIdx = tableDesc.findColumnByName(col).getZeroBasedIndex(); int returnIdx = tableDesc.findColumnByName(returnCol).getZeroBasedIndex(); Comparator<T> colComp = getComparator(colIdx); Comparator<T> returnComp = getComparator(returnIdx); T returnBegin = null; T returnEnd = null; for (T[] row : data.values()) { if (between(beginValue, row[colIdx], endValue, colComp)) { T returnValue = row[returnIdx]; if (returnBegin == null || returnComp.compare(returnValue, returnBegin) < 0) { returnBegin = returnValue; } if (returnEnd == null || returnComp.compare(returnValue, returnEnd) > 0) { returnEnd = returnValue; } } } if (returnBegin == null && returnEnd == null) return null; else return Pair.newPair(returnBegin, returnEnd); }