Java Code Examples for java.util.ArrayDeque#forEach()

The following examples show how to use java.util.ArrayDeque#forEach() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Board.java    From lizzie with GNU General Public License v3.0 6 votes vote down vote up
public static String asName(int c, boolean isName) {
  if (boardWidth > 25 && isName) {
    return String.valueOf(c + 1);
  }
  StringBuilder name = new StringBuilder();
  int base = alphabet.length();
  int n = c;
  ArrayDeque<Integer> ad = new ArrayDeque<Integer>();
  if (n > 0) {
    while (n > 0) {
      ad.addFirst(n < 25 && c >= 25 ? n % base - 1 : n % base);
      n /= base;
    }
  } else {
    ad.addFirst(n);
  }
  ad.forEach(i -> name.append(alphabet.charAt(i)));
  return name.toString();
}
 
Example 2
Source File: HeaderMapDeserializer.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
 */
@Override
public HeaderMap deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    HeaderMap map = new HeaderMap();

    while (p.nextToken() != JsonToken.END_OBJECT) {
        String name = p.getCurrentName();

        p.nextToken();

        if (p.currentToken().isScalarValue()) {
            map.add(name, p.getValueAsString());
        } else {
            ArrayDeque<String> values = new ArrayDeque<>();
            while (p.nextToken() != JsonToken.END_ARRAY) {
                values.push(p.getValueAsString());
            }
            values.forEach(value -> map.add(name, value));
        }
    }
    return map;
}
 
Example 3
Source File: ProjectViewTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void collapsePath(TreePath path) {
  int row = Registry.is("async.project.view.collapse.tree.path.recursively") ? getRowForPath(path) : -1;
  if (row < 0) {
    super.collapsePath(path);
  }
  else {
    ArrayDeque<TreePath> deque = new ArrayDeque<>();
    deque.addFirst(path);
    while (++row < getRowCount()) {
      TreePath next = getPathForRow(row);
      if (!path.isDescendant(next)) break;
      if (isExpanded(next)) deque.addFirst(next);
    }
    deque.forEach(super::collapsePath);
  }
}