private static void handleScan(String[] tokens, String table, DB db) { if (tokens.length < 3) { System.out.println("Error: syntax is \"scan keyname scanlength [field1 field2 ...]\""); } else { Set<String> fields = null; if (tokens.length > 3) { fields = new HashSet<>(); fields.addAll(Arrays.asList(tokens).subList(3, tokens.length)); } Vector<HashMap<String, ByteIterator>> results = new Vector<>(); Status ret = db.scan(table, tokens[1], Integer.parseInt(tokens[2]), fields, results); System.out.println("Result: " + ret.getName()); int record = 0; if (results.isEmpty()) { System.out.println("0 records"); } else { System.out.println("--------------------------------"); } for (Map<String, ByteIterator> result : results) { System.out.println("Record " + (record++)); for (Map.Entry<String, ByteIterator> ent : result.entrySet()) { System.out.println(ent.getKey() + "=" + ent.getValue()); } System.out.println("--------------------------------"); } } }
/** * Create a single AudioInputStream from a vector of AudioInputStreams. The AudioInputStreams are expected to have the same * AudioFormat. * * @param audioInputStreams * a vector containing one or more AudioInputStreams. * @return a single AudioInputStream * @throws NullPointerException * if any of the arguments are null * @throws IllegalArgumentException * if the vector contains no elements, any element is not an AudioInputStream. */ public static AudioInputStream createSingleAudioInputStream(Vector<AudioInputStream> audioInputStreams) { if (audioInputStreams == null) throw new NullPointerException("Received null vector of AudioInputStreams"); if (audioInputStreams.isEmpty()) throw new IllegalArgumentException("Received empty vector of AudioInputStreams"); AudioInputStream singleStream; if (audioInputStreams.size() == 1) singleStream = (AudioInputStream) audioInputStreams.get(0); else { AudioFormat audioFormat = ((AudioInputStream) audioInputStreams.get(0)).getFormat(); singleStream = new SequenceAudioInputStream(audioFormat, audioInputStreams); } return singleStream; }
if (passedTokens.contains(parent) && !duplicateToken) { duplicateToken = true; System.out.println( "Infinite loop in tokens. Currently known tokens : " + passedTokens.toString() + "\nProblem token : " + beginToken } else if (duplicateToken) { if (!passedTokens.isEmpty()) { value = passedTokens.remove(passedTokens.size() - 1); if (passedTokens.isEmpty()) { value = beginToken + value + endToken; duplicateToken = false; } else if (!passedTokens.isEmpty()) { passedTokens.remove(passedTokens.size() - 1);
public static int itFunc(int m, int n){ Stack<Integer> s = new Stack<Integer>; s.add(m); while(!s.isEmpty()){ m=s.pop(); if(m==0||n==0) n+=m+1; else{ s.add(--m); s.add(++m); n--; } } return n; }
/** Push new diagnostic context information for the current thread. <p>The contents of the <code>message</code> parameter is determined solely by the client. @param message The new diagnostic context information. */ public static void push(String message) { Thread key = Thread.currentThread(); Stack stack = (Stack) ht.get(key); if(stack == null) { DiagnosticContext dc = new DiagnosticContext(message, null); stack = new Stack(); ht.put(key, stack); stack.push(dc); } else if (stack.isEmpty()) { DiagnosticContext dc = new DiagnosticContext(message, null); stack.push(dc); } else { DiagnosticContext parent = (DiagnosticContext) stack.peek(); stack.push(new DiagnosticContext(message, parent)); } }
/** Clients should call this method before leaving a diagnostic context. <p>The returned value is the value that was pushed last. If no context is available, then the empty string "" is returned. @return String The innermost diagnostic context. */ public static String pop() { Thread key = Thread.currentThread(); Stack stack = (Stack) ht.get(key); if(stack != null && !stack.isEmpty()) return ((DiagnosticContext) stack.pop()).message; else return ""; }
/** * Create a single AudioInputStream from a vector of AudioInputStreams. The AudioInputStreams are expected to have the same * AudioFormat. * * @param audioInputStreams * a vector containing one or more AudioInputStreams. * @return a single AudioInputStream * @throws NullPointerException * if any of the arguments are null * @throws IllegalArgumentException * if the vector contains no elements, any element is not an AudioInputStream. */ public static AudioInputStream createSingleAudioInputStream(Vector<AudioInputStream> audioInputStreams) { if (audioInputStreams == null) throw new NullPointerException("Received null vector of AudioInputStreams"); if (audioInputStreams.isEmpty()) throw new IllegalArgumentException("Received empty vector of AudioInputStreams"); AudioInputStream singleStream; if (audioInputStreams.size() == 1) singleStream = (AudioInputStream) audioInputStreams.get(0); else { AudioFormat audioFormat = ((AudioInputStream) audioInputStreams.get(0)).getFormat(); singleStream = new SequenceAudioInputStream(audioFormat, audioInputStreams); } return singleStream; }
return true; Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < str.length(); i++) if (current == '{' || current == '(' || current == '[') stack.push(current); if (stack.isEmpty()) return false; stack.pop(); else return false; return stack.isEmpty();
minStack = new Stack<Integer>(); maxStack = new Stack<Integer>(); minStack.push(value); maxStack.push(value); minStack.pop(); maxStack.pop(); if (minStack.isEmpty()) { return Integer.MAX_VALUE; } else { if (maxStack.isEmpty()) { return Integer.MIN_VALUE; } else {
if (exceptions.isEmpty()) { String key = "PL>" + id + idSeed + "-" + j; entries.put(key, plist.addLast(key, payload)); if (exceptions.isEmpty()) { LOG.info("Job-" + id + ", Add, done: " + iterations); int iterateCount = 0; synchronized (plistLocks(plist)) { if (exceptions.isEmpty()) { Iterator<PListEntry> iterator = plist.iterator(); while (iterator.hasNext() && exceptions.isEmpty()) { iterator.next(); iterateCount++; System.err.println("Count Wrong: " + iterator);