当前位置: 首页>>代码示例>>Java>>正文


Java SortedMap.Entry方法代码示例

本文整理汇总了Java中java.util.SortedMap.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java SortedMap.Entry方法的具体用法?Java SortedMap.Entry怎么用?Java SortedMap.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.SortedMap的用法示例。


在下文中一共展示了SortedMap.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: allPlayedLettersAreNextToEachOther

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks if the played letters are all next to each other (it just checks that all played letters are next to each other,
 * without considering letters played in a previous turn and already disposed on the board)
 *
 * @param playedLetters The letters played in the current turn
 * @param horizontal    True if the played letters are disposed horizontally, false otherwise
 *
 * @return true if the played letters are all next to each other, false otherwise
 */
protected static boolean allPlayedLettersAreNextToEachOther(SortedMap<BoardPosition, LetterInterface> playedLetters, boolean horizontal) {
    Iterator<SortedMap.Entry<BoardPosition, LetterInterface>> playedLettersIterator = playedLetters.entrySet().iterator();
    Map.Entry<BoardPosition, LetterInterface> currentLetter;
    Map.Entry<BoardPosition, LetterInterface> nextLetter;

    currentLetter = playedLettersIterator.next();
    while (playedLettersIterator.hasNext()) {
        nextLetter = playedLettersIterator.next();

        if (horizontal) {
            if (currentLetter.getKey().getColumn() + 1 != nextLetter.getKey().getColumn()) {
                return false;
            }
        } else if (currentLetter.getKey().getLine() + 1 != nextLetter.getKey().getLine()) {
            return false;
        }

        currentLetter = nextLetter;
    }

    return true;
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:32,代码来源:PlayedTurnValidityChecker.java

示例2: printRow

import java.util.SortedMap; //导入方法依赖的package包/类
private void printRow(TRowResult rowResult) {
  // copy values into a TreeMap to get them in sorted order

  TreeMap<String, TCell> sorted = new TreeMap<String, TCell>();
  for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) {
    sorted.put(utf8(column.getKey().array()), column.getValue());
  }

  StringBuilder rowStr = new StringBuilder();
  for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) {
    rowStr.append(entry.getKey());
    rowStr.append(" => ");
    rowStr.append(utf8(entry.getValue().value.array()));
    rowStr.append("; ");
  }
  System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:HttpDoAsClient.java

示例3: printRow

import java.util.SortedMap; //导入方法依赖的package包/类
private void printRow(TRowResult rowResult) {
    // copy values into a TreeMap to get them in sorted order

    TreeMap<String, TCell> sorted = new TreeMap<String, TCell>();
    for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) {
        sorted.put(utf8(column.getKey().array()), column.getValue());
    }

    StringBuilder rowStr = new StringBuilder();
    for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) {
        rowStr.append(entry.getKey());
        rowStr.append(" => ");
        rowStr.append(utf8(entry.getValue().value.array()));
        rowStr.append("; ");
    }
    System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:DemoClient.java

示例4: diameter_origin_realm_blacklist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("diameter_origin_realm_blacklist_list")
public String diameter_origin_realm_blacklist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : DiameterFirewallConfig.diameter_origin_realm_blacklist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:DiameterFirewallAPI_V1_0.java

示例5: diameter_application_id_whitelist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("diameter_application_id_whitelist_list")
public String diameter_application_id_whitelist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : DiameterFirewallConfig.diameter_application_id_whitelist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:DiameterFirewallAPI_V1_0.java

示例6: diameter_command_code_blacklist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("diameter_command_code_blacklist_list")
public String diameter_command_code_blacklist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : DiameterFirewallConfig.diameter_command_code_blacklist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:DiameterFirewallAPI_V1_0.java

示例7: sccp_calling_gt_blacklist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("sccp_calling_gt_blacklist_list")
public String sccp_calling_gt_blacklist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : SS7FirewallConfig.sccp_calling_gt_blacklist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:SS7FirewallAPI_V1_0.java

示例8: tcap_oc_blacklist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("tcap_oc_blacklist_list")
public String tcap_oc_blacklist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : SS7FirewallConfig.tcap_oc_blacklist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:SS7FirewallAPI_V1_0.java

示例9: map_cat2_oc_blacklist_list

import java.util.SortedMap; //导入方法依赖的package包/类
@GET
@Consumes("text/plain")
@Produces("text/plain")
@Path("map_cat2_oc_blacklist_list")
public String map_cat2_oc_blacklist_list() {
    String s = "";
    for (SortedMap.Entry<String, String> entry : SS7FirewallConfig.map_cat2_oc_blacklist.entrySet()) {
        s += entry.getKey() + "\n";
    }
    return s;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:12,代码来源:SS7FirewallAPI_V1_0.java

示例10: playedLettersAreDisposedHorizontally

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks whether the played letters have been played horizontally or not
 *
 * @param playedLetters The letters played in the current turn
 *
 * @return True if the letters have been played horizontally, false otherwise
 * @throws InvalidPlayedTurnException if the letters haven't been played horizontally, nor vertically
 */
protected static boolean playedLettersAreDisposedHorizontally(SortedMap<BoardPosition, LetterInterface> playedLetters) throws InvalidPlayedTurnException {
    Iterator<SortedMap.Entry<BoardPosition, LetterInterface>> playedLettersIterator = playedLetters.entrySet().iterator();

    Map.Entry<BoardPosition, LetterInterface> firstLetter = playedLettersIterator.next();

    // If there is only one letter played
    if (!playedLettersIterator.hasNext()) {
        return true;
    }

    Map.Entry<BoardPosition, LetterInterface> nextLetter = playedLettersIterator.next();

    boolean horizontal;
    if (firstLetter.getKey().getLine() == nextLetter.getKey().getLine()) {
        horizontal = true;
    } else if (firstLetter.getKey().getColumn() == nextLetter.getKey().getColumn()) {
        horizontal = false;
    } else {
        throw new InvalidPlayedTurnException("exceptions.invalidPlayedTurn.lettersNotOnSameAxis");
    }

    // Checks if the letters are played on the same axis
    while (playedLettersIterator.hasNext()) {
        nextLetter = playedLettersIterator.next();

        if (horizontal) {
            if (firstLetter.getKey().getLine() != nextLetter.getKey().getLine()) {
                throw new InvalidPlayedTurnException("exceptions.invalidPlayedTurn.lettersNotOnSameAxis");
            }
        } else {
            if (firstLetter.getKey().getColumn() != nextLetter.getKey().getColumn()) {
                throw new InvalidPlayedTurnException("exceptions.invalidPlayedTurn.lettersNotOnSameAxis");
            }
        }
    }

    return horizontal;
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:47,代码来源:PlayedTurnValidityChecker.java

示例11: allPlayedLettersAreDisposedNextToOtherLetters

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks if the played letters are all disposed next to each other or/and next to already played letters
 *
 * @param board         The actual board
 * @param playedLetters The letters played in the current turn
 * @param horizontal    True if the played letters are disposed horizontally, false otherwise
 *
 * @return true if the played letters are all next to each other or to already played letters
 */
protected static boolean allPlayedLettersAreDisposedNextToOtherLetters(BoardInterface board, SortedMap<BoardPosition, LetterInterface> playedLetters, boolean horizontal) {
    // First, we check that all played letters are linked to other letters, without any "hole" (a square without letter on)
    // between the first and the last played letter
    Iterator<SortedMap.Entry<BoardPosition, LetterInterface>> playedLettersIterator = playedLetters.entrySet().iterator();
    if (horizontal) {
        for (int column = playedLetters.firstKey().getColumn(); column < BoardInterface.BOARD_SIZE && playedLettersIterator.hasNext(); column++) {
            if (null == board.getLetters().get(playedLetters.firstKey().getLine()).get(column) && column != playedLettersIterator.next().getKey().getColumn()) {
                return false;
            }
        }
    } else {
        for (int line = playedLetters.firstKey().getLine(); line < BoardInterface.BOARD_SIZE && playedLettersIterator.hasNext(); line++) {
            if (null == board.getLetters().get(line).get(playedLetters.firstKey().getColumn()) && line != playedLettersIterator.next().getKey().getLine()) {
                return false;
            }
        }
    }

    // Finally, we check that at least one letter is played next to a board letter (played in a previous turn)
    for (SortedMap.Entry<BoardPosition, LetterInterface> playedLetter : playedLetters.entrySet()) {
        if (PlayedTurnValidityChecker.hasAdjacentBoardLetter(board, playedLetter)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:37,代码来源:PlayedTurnValidityChecker.java

示例12: addVerticalWordFormedFromOnePlayedLetter

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks if a word can be formed vertically from one played letter, and if so, checks if this word exists and adds
 * it to the played words
 *
 * @param dictionary   The dictionary used to check words existence
 * @param player       The player who played the word
 * @param playedWords  The actual played words
 * @param board        The actual board
 * @param playedLetter The played letter
 *
 * @throws InvalidPlayedTurnException if the formed word doesn't exist
 */
protected static void addVerticalWordFormedFromOnePlayedLetter(DictionaryInterface dictionary, PlayerInterface player, List<WordInterface> playedWords, BoardInterface board, SortedMap.Entry<BoardPosition, LetterInterface> playedLetter) throws InvalidPlayedTurnException {
    if (!PlayedTurnValidityChecker.playedLetterHasBoardLetterAbove(board, playedLetter) && !PlayedTurnValidityChecker.playedLetterHasBoardLetterBelow(board, playedLetter)) {
        return;
    }

    int currentLine = 0;
    while (playedLetter.getKey().getLine() - currentLine - 1 >= 0 && null != board.getLetters().get(playedLetter.getKey().getLine() - currentLine - 1).get(playedLetter.getKey().getColumn())) {
        currentLine++;
    }

    short startLine = (short) (playedLetter.getKey().getLine() - currentLine);
    currentLine = startLine;
    LetterInterface currentLetter;
    List<LetterInterface> wordLetters = new ArrayList<>();
    do {
        if (null != board.getLetters().get(currentLine).get(playedLetter.getKey().getColumn())) {
            currentLetter = board.getLetters().get(currentLine).get(playedLetter.getKey().getColumn());
        } else if (playedLetter.getKey().getLine() == currentLine) {
            currentLetter = playedLetter.getValue();
        } else {
            break;
        }

        wordLetters.add(currentLetter);
        currentLine++;
    } while (currentLine < BoardInterface.BOARD_SIZE);

    PlayedTurnValidityChecker.addWordAfterChecking(dictionary, playedWords, player, wordLetters, false, startLine, playedLetter.getKey().getColumn());
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:42,代码来源:PlayedTurnValidityChecker.java

示例13: addHorizontalWordFormedFromOnePlayedLetter

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks if a word can be formed horizontally from one played letter, and if so, checks if this word exists and adds
 * it to the played words
 *
 * @param dictionary   The dictionary used to check words existence
 * @param player       The player who played the word
 * @param playedWords  The actual played words
 * @param board        The actual board
 * @param playedLetter The played letter
 *
 * @throws InvalidPlayedTurnException if the formed word doesn't exist
 */
protected static void addHorizontalWordFormedFromOnePlayedLetter(DictionaryInterface dictionary, PlayerInterface player, List<WordInterface> playedWords, BoardInterface board, SortedMap.Entry<BoardPosition, LetterInterface> playedLetter) throws InvalidPlayedTurnException {
    if (!PlayedTurnValidityChecker.playedLetterHasBoardLetterAtLeft(board, playedLetter) && !PlayedTurnValidityChecker.playedLetterHasBoardLetterAtRight(board, playedLetter)) {
        return;
    }

    int currentColumn = 0;
    while (playedLetter.getKey().getColumn() - currentColumn - 1 >= 0 && null != board.getLetters().get(playedLetter.getKey().getLine()).get(playedLetter.getKey().getColumn() - currentColumn - 1)) {
        currentColumn++;
    }

    short startColumn = (short) (playedLetter.getKey().getColumn() - currentColumn);
    currentColumn = startColumn;
    LetterInterface currentLetter;
    List<LetterInterface> wordLetters = new ArrayList<>();
    do {
        if (null != board.getLetters().get(playedLetter.getKey().getLine()).get(currentColumn)) {
            currentLetter = board.getLetters().get(playedLetter.getKey().getLine()).get(currentColumn);
        } else if (playedLetter.getKey().getColumn() == currentColumn) {
            currentLetter = playedLetter.getValue();
        } else {
            break;
        }

        wordLetters.add(currentLetter);
        currentColumn++;
    } while (currentColumn < BoardInterface.BOARD_SIZE);

    PlayedTurnValidityChecker.addWordAfterChecking(dictionary, playedWords, player, wordLetters, true, playedLetter.getKey().getLine(), startColumn);
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:42,代码来源:PlayedTurnValidityChecker.java

示例14: addLetters

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public void addLetters(SortedMap<BoardPosition, LetterInterface> letters) {
    for (SortedMap.Entry<BoardPosition, LetterInterface> playedEntry : letters.entrySet()) {
        this.letters.get(playedEntry.getKey().getLine()).set(playedEntry.getKey().getColumn(), playedEntry.getValue());
    }
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:7,代码来源:Board.java

示例15: hasAdjacentBoardLetter

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Checks if the given letter has an adjacent board letter
 *
 * @param board        The actual board
 * @param playedLetter The played letter
 *
 * @return true if the letter has an adjacent board letter, false otherwise
 */
protected static boolean hasAdjacentBoardLetter(BoardInterface board, SortedMap.Entry<BoardPosition, LetterInterface> playedLetter) {
    return PlayedTurnValidityChecker.playedLetterHasBoardLetterAbove(board, playedLetter) || PlayedTurnValidityChecker.playedLetterHasBoardLetterAtRight(board, playedLetter) || PlayedTurnValidityChecker.playedLetterHasBoardLetterBelow(board, playedLetter) || PlayedTurnValidityChecker.playedLetterHasBoardLetterAtLeft(board, playedLetter);
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:12,代码来源:PlayedTurnValidityChecker.java


注:本文中的java.util.SortedMap.Entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。