use of java.util.ArrayDeque in project checkstyle by checkstyle.
the class RequireThisCheck method getAllTokensWhichAreEqualToCurrent.
/**
* Collects all tokens which are equal to current token starting with the current ast node and
* which line number is lower or equal to the end line number.
* @param ast ast node.
* @param token token.
* @param endLineNumber end line number.
* @return a set of tokens which are equal to current token starting with the current ast node
* and which line number is lower or equal to the end line number.
*/
private static Set<DetailAST> getAllTokensWhichAreEqualToCurrent(DetailAST ast, DetailAST token, int endLineNumber) {
DetailAST vertex = ast;
final Set<DetailAST> result = new HashSet<>();
final Deque<DetailAST> stack = new ArrayDeque<>();
while (vertex != null || !stack.isEmpty()) {
if (!stack.isEmpty()) {
vertex = stack.pop();
}
while (vertex != null) {
if (token.equals(vertex) && vertex.getLineNo() <= endLineNumber) {
result.add(vertex);
}
if (vertex.getNextSibling() != null) {
stack.push(vertex.getNextSibling());
}
vertex = vertex.getFirstChild();
}
}
return result;
}
use of java.util.ArrayDeque in project hive by apache.
the class PTFDeserializer method initializePTFChain.
public void initializePTFChain(PartitionedTableFunctionDef tblFnDef) throws HiveException {
Deque<PTFInputDef> ptfChain = new ArrayDeque<PTFInputDef>();
PTFInputDef currentDef = tblFnDef;
while (currentDef != null) {
ptfChain.push(currentDef);
currentDef = currentDef.getInput();
}
while (!ptfChain.isEmpty()) {
currentDef = ptfChain.pop();
if (currentDef instanceof PTFQueryInputDef) {
initialize((PTFQueryInputDef) currentDef, inputOI);
} else if (currentDef instanceof WindowTableFunctionDef) {
initializeWindowing((WindowTableFunctionDef) currentDef);
} else {
initialize((PartitionedTableFunctionDef) currentDef);
}
}
PTFDeserializer.alterOutputOIForStreaming(ptfDesc);
}
use of java.util.ArrayDeque in project mongomvcc by igd-geo.
the class Index method readCommit.
/**
* Iteratively reads the information from the given commit and all its
* ancestors and builds up the index
* @param c the commit to read
* @param tree the tree of commits
*/
private void readCommit(Commit c, Tree tree) {
ArrayDeque<Commit> stack = new ArrayDeque<Commit>();
while (true) {
//iteratively read parent commit (if there is any)
stack.addLast(c);
long cid = c.getParentCID();
if (cid == 0) {
break;
}
c = tree.resolveCommit(cid);
}
while (!stack.isEmpty()) {
c = stack.removeLast();
//read objects from the given commit and put them into the index
for (Map.Entry<String, IdMap> e : c.getObjects().entrySet()) {
IdMap m = getObjects(e.getKey());
IdSet o = getOIDs(e.getKey());
IdMapIterator it = e.getValue().iterator();
while (it.hasNext()) {
it.advance();
if (it.value() < 0) {
//deleted object
long prev = m.get(it.key());
if (prev != 0) {
m.remove(it.key());
o.remove(prev);
}
} else {
long prev = m.put(it.key(), it.value());
if (prev != 0) {
//overwrite object with new value
o.remove(prev);
}
o.add(it.value());
}
}
}
}
}
use of java.util.ArrayDeque in project mapdb by jankotek.
the class ArrayDequeTest method testAdd.
/**
* add(x) succeeds
*/
public void testAdd() {
ArrayDeque q = new ArrayDeque();
assertTrue(q.add(zero));
assertTrue(q.add(one));
assertSame(zero, q.peekFirst());
assertSame(one, q.peekLast());
}
use of java.util.ArrayDeque in project mapdb by jankotek.
the class ArrayDequeTest method testAddAll1.
/**
* addAll(null) throws NPE
*/
public void testAddAll1() {
ArrayDeque q = new ArrayDeque();
try {
q.addAll(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
Aggregations