java.util.Vector.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(173)

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

Vector.isEmpty介绍

[英]Returns if this vector has no elements, a size of zero.
[中]如果此向量没有元素,则返回大小为零的值。

代码示例

代码示例来源:origin: stackoverflow.com

Stack<String> stack = new Stack<String>();
 stack.push("1");
 stack.push("2");
 stack.push("3");
 stack.insertElementAt("squeeze me in!", 1);
 while (!stack.isEmpty()) {
   System.out.println(stack.pop());
 }
 // prints "3", "2", "squeeze me in!", "1"

代码示例来源:origin: brianfrankcooper/YCSB

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("--------------------------------");
  }
 }
}

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

/**
 * 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;
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

/**
 * Pop the current context node list.
 * @xsl.usage internal
 */
public final void popContextNodeList()
{
  if(m_contextNodeLists.isEmpty())
   System.err.println("Warning: popContextNodeList when stack is empty!");
  else
  m_contextNodeLists.pop();
}

代码示例来源:origin: org.apache.ant/ant

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);

代码示例来源:origin: stackoverflow.com

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;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  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));
 }    
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  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 "";
}

代码示例来源:origin: stackoverflow.com

private void printFiles(File dir) {
 Stack<File> stack = new Stack<File>();
 stack.push(dir);
 while(!stack.isEmpty()) {
  File child = stack.pop();
  if (child.isDirectory()) {
   for(File f : child.listFiles()) stack.push(f);
  } else if (child.isFile()) {
   System.out.println(child.getPath());
  }
 }
}

代码示例来源:origin: brianfrankcooper/YCSB

.println("Doing read from Hypertable columnfamily " + columnFamily);
System.out.println("Doing read for key: " + key);
  return Status.ERROR;
 if (!resMap.isEmpty()) {
  result.putAll(resMap.firstElement());
 System.err.println("Error doing read: " + e.message);

代码示例来源:origin: org.apache.karaf.bundles/org.apache.karaf.bundles.xalan-2.7.1

/**
 * Pop the current context node list.
 * @xsl.usage internal
 */
public final void popContextNodeList()
{
  if(m_contextNodeLists.isEmpty())
   System.err.println("Warning: popContextNodeList when stack is empty!");
  else
  m_contextNodeLists.pop();
}

代码示例来源:origin: google/sagetv

private static EvaluatorVisitor getEVFromPool()
{
 synchronized (pooledEVs)
 {
  if (!pooledEVs.isEmpty())
   return (EvaluatorVisitor) pooledEVs.remove(pooledEVs.size() - 1);
  else
  {
   if (sage.Sage.DBG) System.out.println("EVPoolSize=" + (++numEVsCreated));
   return new EvaluatorVisitor();
  }
 }
}

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

/**
 * 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;
}

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: mpetazzoni/ttorrent

parser.parse(args);
} catch (CmdLineParser.OptionException oe) {
 System.err.println(oe.getMessage());
 usage(System.err);
 System.exit(1);
    (otherArgs.length != 1 || announceURLs.isEmpty())) {
 usage(System.err, "Announce URL and a file or directory must be " +
     "provided to create a torrent file!");

代码示例来源:origin: stackoverflow.com

public void print(Stack s)
{
  while(!s.isEmpty())
  {
    System.out.println(s.pop());
  }

}

代码示例来源:origin: org.apache.ant/ant

final int size = names.size();
for (int i = 0; i < size; i++) {
  msg.append(" ");
  if (!dependencies.isEmpty() && dependencies.elementAt(i).hasMoreElements()) {
    msg.append(StreamUtils.enumerationAsStream(dependencies.elementAt(i))
        .collect(Collectors.joining(", ", "   depends on: ", eol)));

代码示例来源:origin: stackoverflow.com

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 {

代码示例来源:origin: apache/activemq

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);

代码示例来源:origin: stackoverflow.com

Stack<Integer> lifoCopy = (Stack<Integer>) lifo.clone();
int max = Integer.MIN_VALUE;

while (!lifoCopy.isEmpty())
{
  max = Math.max(lifoCopy.pop(), max);
}

System.out.println("max=" + max.toString());

相关文章

微信公众号

最新文章

更多