private void UpdateStateQueue(
      MinPriorityDecoderQueue<DecoderState> minPriorityDecoderQueue,
      DecoderState curState,
      DecoderState prevState,
      ScoredPhrasePairForSentence phrase,
      HashMap<DecoderState, BackPointerElement> backPointers) {
    BackPointerElement elem = backPointers.get(curState);

    if (elem == null || elem.getState().getScore() < curState.getScore()) {
      minPriorityDecoderQueue.insert(curState, curState.getScore());

      if (elem == null) {
        backPointers.put(curState, new BackPointerElement(prevState, phrase));
      } else {
        elem.setState(prevState);
        elem.setPhrase(phrase);
      }
    }
  }
  private List<ScoredPhrasePairForSentence> readBackPointers(
      DecoderState state,
      List<HashMap<DecoderState, BackPointerElement>> backPointersList,
      int startLength,
      int sentenceLength) {
    DecoderState curState = state;
    DecoderState startState = getStartState(sentenceLength);

    int curLength = startLength;

    List<ScoredPhrasePairForSentence> phrases = new ArrayList<>();
    while (!curState.equals(startState)) {
      BackPointerElement backPointer = backPointersList.get(curLength).get(curState);
      phrases.add(0, backPointer.getPhrase());
      curState = backPointer.getState();
      curLength = decoderModel.getDecodedLength(curState);
    }

    return phrases;
  }