org.jline.reader.History.reverseIterator()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.jline.reader.History.reverseIterator()方法的一些代码示例,展示了History.reverseIterator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。History.reverseIterator()方法的具体详情如下:
包路径:org.jline.reader.History
类名称:History
方法名:reverseIterator

History.reverseIterator介绍

暂无

代码示例

代码示例来源:origin: org.jline/jline

default Iterator<Entry> reverseIterator() {
  return reverseIterator(last());
}

代码示例来源:origin: julianhyde/sqlline

private String calculateCommand(int currentOffset, Set<Integer> offsets) {
 if (!offsets.add(currentOffset)) {
  throw new IllegalArgumentException(
    "Cycled rerun of commands from history " + offsets);
 }
 History history = sqlLine.getLineReader().getHistory();
 Iterator<History.Entry> iterator = currentOffset > 0
   ? history.iterator(currentOffset - 1)
   : history.reverseIterator(history.size() - 1 + currentOffset);
 String command = iterator.next().line();
 if (command.trim().startsWith("!/") || command.startsWith("!rerun")) {
  String[] cmd = sqlLine.split(command);
  if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
   return command;
  }
  int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]);
  if (history.size() < offset || history.size() - 1 < -offset) {
   return command;
  }
  return calculateCommand(offset, offsets);
 }
 return command;
}

代码示例来源:origin: sqlline/sqlline

private String calculateCommand(int currentOffset, Set<Integer> offsets) {
 if (!offsets.add(currentOffset)) {
  throw new IllegalArgumentException(
    "Cycled rerun of commands from history " + offsets);
 }
 History history = sqlLine.getLineReader().getHistory();
 Iterator<History.Entry> iterator = currentOffset > 0
   ? history.iterator(currentOffset - 1)
   : history.reverseIterator(history.size() - 1 + currentOffset);
 String command = iterator.next().line();
 if (command.trim().startsWith("!/") || command.startsWith("!rerun")) {
  String[] cmd = sqlLine.split(command);
  if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
   return command;
  }
  int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]);
  if (history.size() < offset || history.size() - 1 < -offset) {
   return command;
  }
  return calculateCommand(offset, offsets);
 }
 return command;
}

代码示例来源:origin: org.jline/jline

if (pair == null) {
  pair = StreamSupport.stream(
      Spliterators.spliteratorUnknownSize(history.reverseIterator(searchIndex < 0 ? history.last() : searchIndex - 1), Spliterator.ORDERED), false)
      .flatMap(e -> matches(pat, e.line(), e.index()).stream())
      .findFirst()

相关文章