java.util.Hashtable.size()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(166)

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

Hashtable.size介绍

[英]The number of mappings in this hash map.
[中]此哈希映射中的映射数。

代码示例

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

public SortedKeyEnumeration(Hashtable ht) {
 Enumeration f = ht.keys();
 Vector keys = new Vector(ht.size());
 for (int i, last = 0; f.hasMoreElements(); ++last) {
  String key = (String) f.nextElement();
  for (i = 0; i < last; ++i) {
   String s = (String) keys.get(i);
   if (key.compareTo(s) <= 0) break;
  }
  keys.add(i, key);
 }
 e = keys.elements();
}

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

public Enumeration getCurrentLoggers() {
  Vector<Logger> loggers = new Vector<Logger>(ht.size());
  Enumeration elems = ht.elements();
  while (elems.hasMoreElements()) {
    Object o = elems.nextElement();
    if (o instanceof Logger) {
      Logger logger = (Logger)o;
      loggers.addElement(logger);
    }
  }
  return loggers.elements();
}

代码示例来源:origin: Sable/soot

public void removeEdge(Object from, Object to) {
 Hashtable targets = sources.get(from);
 if (targets == null) {
  return;
 }
 targets.remove(to);
 if (targets.size() == 0) {
  sources.remove(from);
 }
}

代码示例来源:origin: Sable/soot

public void addAll(WeightedDirectedSparseGraph othergraph) {
 WeightedDirectedSparseGraph another = othergraph;
 this.isUnknown = another.isUnknown;
 this.clear();
 Hashtable<Object, Hashtable<Object, IntContainer>> othersources = another.sources;
 Iterator<Object> othersrcIt = othersources.keySet().iterator();
 while (othersrcIt.hasNext()) {
  Object src = othersrcIt.next();
  Hashtable othertargets = othersources.get(src);
  Hashtable<Object, IntContainer> thistargets = new Hashtable<Object, IntContainer>(othersources.size());
  this.sources.put(src, thistargets);
  Iterator targetIt = othertargets.keySet().iterator();
  while (targetIt.hasNext()) {
   Object target = targetIt.next();
   IntContainer otherweight = (IntContainer) othertargets.get(target);
   thistargets.put(target, otherweight.dup());
  }
 }
}

代码示例来源:origin: quartz-scheduler/quartz

public static InitialContext getInitialContext(final JobDataMap dataMap)
    throws NamingException {
  final Hashtable<String, String> params = new Hashtable<String, String>(4);
  final String initialContextFactory = dataMap
      .getString(INITIAL_CONTEXT_FACTORY);
  if (initialContextFactory != null)
    params.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
  final String providerUrl = dataMap.getString(PROVIDER_URL);
  if (providerUrl != null)
    params.put(Context.PROVIDER_URL, providerUrl);
  final String principal = dataMap.getString(PRINCIPAL);
  if (principal != null)
    params.put(Context.SECURITY_PRINCIPAL, principal);
  final String credentials = dataMap.getString(CREDENTIALS);
  if (credentials != null)
    params.put(Context.SECURITY_CREDENTIALS, credentials);
  if (params.size() == 0)
    return new InitialContext();
  else
    return new InitialContext(params);
}

代码示例来源:origin: commons-collections/commons-collections

public void testToListWithHashtable() {
  Hashtable expected = new Hashtable();
  expected.put("one", new Integer(1));
  expected.put("two", new Integer(2));
  expected.put("three", new Integer(3));
  // validate elements.
  List actualEltList = EnumerationUtils.toList(expected.elements());
  Assert.assertEquals(expected.size(), actualEltList.size());
  Assert.assertTrue(actualEltList.contains(new Integer(1)));
  Assert.assertTrue(actualEltList.contains(new Integer(2)));
  Assert.assertTrue(actualEltList.contains(new Integer(3)));
  List expectedEltList = new ArrayList();
  expectedEltList.add(new Integer(1));
  expectedEltList.add(new Integer(2));
  expectedEltList.add(new Integer(3));
  Assert.assertTrue(actualEltList.containsAll(expectedEltList));
  // validate keys.
  List actualKeyList = EnumerationUtils.toList(expected.keys());
  Assert.assertEquals(expected.size(), actualEltList.size());
  Assert.assertTrue(actualKeyList.contains("one"));
  Assert.assertTrue(actualKeyList.contains("two"));
  Assert.assertTrue(actualKeyList.contains("three"));
  List expectedKeyList = new ArrayList();
  expectedKeyList.add("one");
  expectedKeyList.add("two");
  expectedKeyList.add("three");
  Assert.assertTrue(actualKeyList.containsAll(expectedKeyList));
}

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

private static String getPostParamString(Hashtable<String, String> params) {
  if(params.size() == 0)
    return "";

  StringBuffer buf = new StringBuffer();
  Enumeration<String> keys = params.keys();
  while(keys.hasMoreElements()) {
    buf.append(buf.length() == 0 ? "" : "&");
    String key = keys.nextElement();
    buf.append(key).append("=").append(params.get(key));
  }
  return buf.toString();
}

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

/**
  Returns all the currently defined categories in this hierarchy as
  an {@link java.util.Enumeration Enumeration}.
  <p>The root logger is <em>not</em> included in the returned
  {@link Enumeration}.  */
public
Enumeration getCurrentLoggers() {
 // The accumlation in v is necessary because not all elements in
 // ht are Logger objects as there might be some ProvisionNodes
 // as well.
 Vector v = new Vector(ht.size());
 Enumeration elems = ht.elements();
 while(elems.hasMoreElements()) {
  Object o = elems.nextElement();
  if(o instanceof Logger) {
 v.addElement(o);
  }
 }
 return v.elements();
}

代码示例来源:origin: Sable/soot

public void addBoundedAll(WeightedDirectedSparseGraph another) {
 this.isUnknown = another.isUnknown;
 Hashtable<Object, Hashtable<Object, IntContainer>> othersources = another.sources;
 Iterator thisnodeIt = this.vertexes.iterator();
 while (thisnodeIt.hasNext()) {
  Object src = thisnodeIt.next();
  Hashtable othertargets = othersources.get(src);
  if (othertargets == null) {
   continue;
  }
  Hashtable<Object, IntContainer> thistargets = new Hashtable<Object, IntContainer>();
  Iterator othertargetIt = othertargets.keySet().iterator();
  while (othertargetIt.hasNext()) {
   Object key = othertargetIt.next();
   if (this.vertexes.contains(key)) {
    IntContainer weight = (IntContainer) othertargets.get(key);
    thistargets.put(key, weight.dup());
   }
  }
  if (thistargets.size() > 0) {
   this.sources.put(src, thistargets);
  }
 }
}

代码示例来源:origin: quartz-scheduler/quartz

protected InitialContext getInitialContext(JobDataMap jobDataMap)
    throws NamingException {
    Hashtable<String, String> params = new Hashtable<String, String>(2);
    
    String initialContextFactory =
      jobDataMap.getString(INITIAL_CONTEXT_FACTORY);
    if (initialContextFactory != null) {
      params.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
    }
    
    String providerUrl = jobDataMap.getString(PROVIDER_URL);
    if (providerUrl != null) {
      params.put(Context.PROVIDER_URL, providerUrl);
    }

    String principal = jobDataMap.getString(PRINCIPAL);
    if ( principal != null ) {
      params.put( Context.SECURITY_PRINCIPAL, principal );
    }

    String credentials = jobDataMap.getString(CREDENTIALS);
    if ( credentials != null ) {
      params.put( Context.SECURITY_CREDENTIALS, credentials );
    }

    return (params.size() == 0) ? new InitialContext() : new InitialContext(params);
  }    
}

代码示例来源:origin: spring-projects/spring-framework

return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
Object found = this.boundObjects.get(name);
if (found == null) {
  if (!name.endsWith("/")) {
      "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" +
      StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]");

代码示例来源:origin: pentaho/pentaho-kettle

public String[] getUsedFields() {
 Hashtable<String, String> fields = new Hashtable<String, String>();
 getUsedFields( fields );
 String[] retval = new String[fields.size()];
 Enumeration<String> keys = fields.keys();
 int i = 0;
 while ( keys.hasMoreElements() ) {
  retval[i] = keys.nextElement();
  i++;
 }
 return retval;
}

代码示例来源:origin: javahongxi/whatsmars

public Enumeration getCurrentLoggers() {
  Vector<Logger> loggers = new Vector<Logger>(ht.size());
  Enumeration elems = ht.elements();
  while (elems.hasMoreElements()) {
    Object o = elems.nextElement();
    if (o instanceof Logger) {
      Logger logger = (Logger)o;
      loggers.addElement(logger);
    }
  }
  return loggers.elements();
}

代码示例来源:origin: pentaho/pentaho-kettle

files.put( filename, properties );
directories = new Hashtable<String, Integer>( files.size() );
locales = new Hashtable<String, Boolean>( 10 );
 Integer num = directories.get( path );
 if ( num != null ) {
  num = Integer.valueOf( num.intValue() + 1 );
  num = Integer.valueOf( 1 );
 directories.put( path, num );
 locales.put( locale, Boolean.TRUE );

代码示例来源:origin: googlemaps/android-maps-utils

protected void onPostExecute(PointsKeywords pointsKeywords) {
    Collection<LatLng> points = pointsKeywords.points;
    String keyword = pointsKeywords.keyword;
    // Check that it wasn't an empty query.
    if (!points.isEmpty()) {
      if (mOverlays.size() < MAX_CHECKBOXES) {
        makeCheckBox(keyword);
        HeatmapTileProvider provider = new HeatmapTileProvider.Builder()
            .data(new ArrayList<LatLng>(points))
            .gradient(makeGradient(HEATMAP_COLORS[mOverlaysRendered]))
            .build();
        TileOverlay overlay = getMap().addTileOverlay(new TileOverlayOptions().tileProvider(provider));
        mOverlays.put(keyword, overlay);
      }
      mOverlaysRendered++;
      if (mOverlaysRendered == mOverlaysInput) {
        ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
        progressBar.setVisibility(View.GONE);
      }
    } else {
      ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
      progressBar.setVisibility(View.GONE);
      Toast.makeText(HeatmapsPlacesDemoActivity.this, "No results for this query :(", Toast.LENGTH_SHORT).show();
    }
  }
}

代码示例来源:origin: Sable/soot

if (this.sources.size() != othersources.size()) {
 return false;
while (sourceIt.hasNext()) {
 Object src = sourceIt.next();
 Hashtable thistarget = sources.get(src);
 Hashtable othertarget = othersources.get(src);
 if (thistarget.size() != othertarget.size()) {
  return false;
 while (targetIt.hasNext()) {
  Object target = targetIt.next();
  IntContainer thisweight = (IntContainer) thistarget.get(target);
  IntContainer otherweight = (IntContainer) othertarget.get(target);

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

Enumeration enumeration = ht.keys();
 while(enumeration.hasMoreElements() && (misses <= 4)) {
Thread t = (Thread) enumeration.nextElement();
if(t.isAlive()) {
 misses++;
 Thread t = (Thread) v.elementAt(i);
 LogLog.debug("Lazy NDC removal for thread [" + t.getName() + "] ("+ 
    ht.size() + ").");
 ht.remove(t);

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

/**
  Returns all the currently defined categories in this hierarchy as
  an {@link java.util.Enumeration Enumeration}.
  <p>The root logger is <em>not</em> included in the returned
  {@link Enumeration}.  */
public
Enumeration getCurrentLoggers() {
 // The accumlation in v is necessary because not all elements in
 // ht are Logger objects as there might be some ProvisionNodes
 // as well.
 Vector v = new Vector(ht.size());
 Enumeration elems = ht.elements();
 while(elems.hasMoreElements()) {
  Object o = elems.nextElement();
  if(o instanceof Logger) {
 v.addElement(o);
  }
 }
 return v.elements();
}

代码示例来源:origin: Sable/soot

private boolean SSSPFinder(Object src) {
 Hashtable<Object, IntContainer> outedges = sources.get(src);
 if (outedges == null) {
  return true;
 if (outedges.size() == 0) {
  return true;
   WeightedDirectedEdge edge = edgeIt.next();
   IntContainer dfrom = distance.get(edge.from);
   IntContainer dto = distance.get(edge.to);
   if (dto == null) {
    continue;
  IntContainer dist = distance.get(to);
  outedges.put(to, dist.dup());

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

ejbFiles.put(MANIFEST, manifestFile);
ejbFiles.put(META_DIR + EJB_DD,
       new File(config.descriptorDir, descriptorFileName));
         + jarFile.getName()
         + " with "
         + String.valueOf(ejbFiles.size())
         + " files",
         Project.MSG_INFO);

相关文章