Search in sources :

Example 1 with Cell

use of javafx.scene.control.Cell in project leetcode by demonSong.

the class SolutionDay13_L0407 method trapRainWater.

public int trapRainWater(int[][] heightMap) {
    int row = heightMap.length;
    if (row <= 2)
        return 0;
    int col = heightMap[0].length;
    if (col <= 2)
        return 0;
    int[][] dir = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
    // 从最低的cell遍历
    PriorityQueue<Cell> queue = new PriorityQueue<>(1, new Comparator<Cell>() {

        @Override
        public int compare(Cell o1, Cell o2) {
            return o1.height - o2.height;
        }
    });
    boolean[][] visited = new boolean[row][col];
    for (int i = 0; i < row; i++) {
        visited[i][0] = true;
        visited[i][col - 1] = true;
        queue.offer(new Cell(i, 0, heightMap[i][0]));
        queue.offer(new Cell(i, col - 1, heightMap[i][col - 1]));
    }
    for (int i = 0; i < col; i++) {
        visited[0][i] = true;
        visited[row - 1][i] = true;
        queue.offer(new Cell(0, i, heightMap[0][i]));
        queue.offer(new Cell(row - 1, i, heightMap[row - 1][i]));
    }
    int area = 0;
    while (!queue.isEmpty()) {
        Cell cell = queue.poll();
        for (int[] d : dir) {
            int nrow = cell.row + d[0];
            int ncol = cell.col + d[1];
            if (nrow >= 0 && nrow < row && ncol >= 0 && ncol < col && !visited[nrow][ncol]) {
                visited[nrow][ncol] = true;
                area += Math.max(0, cell.height - heightMap[nrow][ncol]);
                queue.offer(new Cell(nrow, ncol, Math.max(heightMap[nrow][ncol], cell.height)));
            }
        }
    }
    return area;
}
Also used : PriorityQueue(java.util.PriorityQueue) Cell(javafx.scene.control.Cell)

Example 2 with Cell

use of javafx.scene.control.Cell in project TestFX by TestFX.

the class ListViewMatchers method hasListCell.

private static boolean hasListCell(ListView listView, Object value) {
    NodeFinder nodeFinder = FxAssert.assertContext().getNodeFinder();
    NodeQuery nodeQuery = nodeFinder.from(listView);
    return nodeQuery.lookup(SELECTOR_LIST_CELL).<Cell>match(cell -> hasCellValue(cell, value)).tryQuery().isPresent();
}
Also used : NodeQuery(org.testfx.service.query.NodeQuery) NodeFinder(org.testfx.service.finder.NodeFinder) Cell(javafx.scene.control.Cell)

Example 3 with Cell

use of javafx.scene.control.Cell in project TestFX by TestFX.

the class TableViewMatchers method hasTableCell.

private static boolean hasTableCell(TableView tableView, Object value) {
    NodeFinder nodeFinder = FxAssert.assertContext().getNodeFinder();
    NodeQuery nodeQuery = nodeFinder.from(tableView);
    return nodeQuery.lookup(SELECTOR_TABLE_CELL).<Cell>match(cell -> hasCellValue(cell, value)).tryQuery().isPresent();
}
Also used : NodeQuery(org.testfx.service.query.NodeQuery) NodeFinder(org.testfx.service.finder.NodeFinder) Cell(javafx.scene.control.Cell)

Aggregations

Cell (javafx.scene.control.Cell)3 NodeFinder (org.testfx.service.finder.NodeFinder)2 NodeQuery (org.testfx.service.query.NodeQuery)2 PriorityQueue (java.util.PriorityQueue)1